Django Admin - Disable the 'Add' action for a specific model Django Admin - Disable the 'Add' action for a specific model django django

Django Admin - Disable the 'Add' action for a specific model


It is easy, just overload has_add_permission method in your Admin class like so:

class MyAdmin(admin.ModelAdmin):     def has_add_permission(self, request, obj=None):        return False


I think this will help you..below code must be in admin.py file

@admin.register(Author)class AuthorAdmin(admin.ModelAdmin):    list_display = ('name', )    list_filter = ('name', )    search_fields = ('name', )    list_per_page = 20    # This will help you to disbale add functionality    def has_add_permission(self, request):        return False    # This will help you to disable delete functionaliyt    def has_delete_permission(self, request, obj=None):        return False

In additon to the above as posted by

    # This will help you to disable change functionality    def has_change_permission(self, request, obj=None):        return False


By default syncdb creates 3 security permissions for each model:

  1. Create (aka add)
  2. Change
  3. Delete

If your logged in as Admin, you get EVERYTHING no matter what.

But if you create a new user group called "General Access" (for example) then you can assign ONLY the CHANGE and DELETE permissions for all of your models.

Then any logged in user that is a member of that group will not have "Create" permission, nothing related to it will show on the screen.