-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added chapter for removing delete button
- Loading branch information
Showing
5 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
How to remove the 'Add'/'Delete' button for a model? | ||
==================================================== | ||
|
||
|
||
The UMSRA management has added all the Category and Origin objects and wants to disable any further addition and deletion. | ||
They have asked you to disable 'Add' and 'Delete' buttons. You can do this by overriding the | ||
:code:`has_add_permission` and :code:`has_delete_permission` in the Django admin.:: | ||
|
||
|
||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
def has_delete_permission(self, request, obj=None): | ||
return False | ||
|
||
|
||
With these changes, the admin looks like this | ||
|
||
.. image:: remove_add_perms.png | ||
|
||
Note the removed `Add` buttons. The add and delete buttons also get removed from the detail pages. You can also read :doc:`remove_delete_selected`. | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters