Created
August 11, 2011 15:53
-
-
Save benregn/1139995 to your computer and use it in GitHub Desktop.
Only show certain fields when editing in Django
This file contains hidden or 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 SomeForm(forms.ModelForm): | |
| class Meta: | |
| model = SomeModel | |
| def __init__(self, *args, **kwargs): | |
| super(SomeForm, self).__init__(*args, **kwargs) | |
| if self.instance: | |
| print "There is an instance, so were editing." | |
| self.fields['anewfieldonlywhenediting'] = forms.CharField() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment