[Answer]-Limit the number of objects in django admin

1👍

Add this method to PollAdmin:

def has_add_permission(self, request):
    return Poll.objects.all().count() == 0

0👍

I assume you are using django > 1.2.

class PollAdmin(admin.ModelAdmin):

   def has_add_permission(self, request):
       return not Poll.objects.exists()   # cheaper than Poll.objects.count() on most of the db
👤sax

Leave a comment