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
- [Answer]-Django post list json
- [Answer]-Django automatically fill user detail
- [Answer]-Django cutom image name on upload
Source:stackexchange.com