Created
November 3, 2016 06:44
-
-
Save bluethon/901f4e01115f30b2142b381bc8d08d36 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/13817525/django-admin-make-all-fields-readonly
使admin中所有字段只读
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
class CustomAdmin(admin.ModelAdmin): | |
def get_readonly_fields(self, request, obj=None): | |
# ... | |
return [f.name for f in self.model._meta.fields] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment