Reputation: 371
How I can show the number of models.ManyToManyField
as a number but not editable because when I set editable=False
I couldn't see the number of users in the Django model
like this
viewers = models.ManyToManyField(Account, editable=False)
Upvotes: 1
Views: 34
Reputation: 2235
Use readonly_fields
in admin.py
admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
....
readonly_fields = ['id','viewers']
Upvotes: 2