As a βreal-world example,β consider a user model in which the email address and username always match, and then you can overwrite the ModelForm save method, for example:
class UserForm(forms.ModelForm): ... def save(self):
If you did not use commit=False to set the username to the email address, you will either have to change the way the user model is saved, or save the user object twice (which duplicates the expensive database operation.)
Mark Chackerian Jun 14 '16 at 19:27 2016-06-14 19:27
source share