-
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.
- Loading branch information
Showing
5 changed files
with
21 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
How to mark a field as readonly in admin? | ||
++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
UMSRA has temporarily decided to stop tracking the family trees of mythological entities. You have been asked to make the :code:`father`, :code:`mother` and :code:`spouse` fields readonly. | ||
|
||
You can do this by:: | ||
|
||
@admin.register(Hero) | ||
class HeroAdmin(admin.ModelAdmin, ExportCsvMixin): | ||
... | ||
readonly_fields = ["father", "mother", "spouse"] | ||
|
||
Your create form looks like this: | ||
|
||
.. image::changeview_readonly.png |
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