Skip to content

Instantly share code, notes, and snippets.

@gtsalles
Created January 22, 2016 20:40
Show Gist options
  • Save gtsalles/d07c584b4c657bf143dc to your computer and use it in GitHub Desktop.
Save gtsalles/d07c584b4c657bf143dc to your computer and use it in GitHub Desktop.
Exemplo de readonly_fields dinâmico no admin do django
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