Created
November 24, 2014 03:19
-
-
Save victorono/f5180f3bb992efa204cb to your computer and use it in GitHub Desktop.
Django forms: default value if user leaves field blank
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 YourForm(forms.Form): | |
| ... | |
| def clean_field(self): | |
| data = self.cleaned_data['field'] | |
| if not data: | |
| data = self.instance.field | |
| return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment