Created
January 22, 2016 20:40
-
-
Save gtsalles/d07c584b4c657bf143dc to your computer and use it in GitHub Desktop.
Exemplo de readonly_fields dinâmico no admin do django
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
def get_form(self, request, obj=None, **kwargs): | |
if obj: | |
self.readonly_fields = ('employer',) | |
else: | |
self.readonly_fields = () | |
return super(ScoreAdmin, self).get_form(request, obj, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment