0👍
✅
Just change your user
instance before passing it to the form. The data will not be saved unless you call user.save()
explicitly.
👤jeyk
1👍
I know this is old and I don’t know if this is exactly what you were asking for, but this might help to someone else:
class UserForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
kwargs['initial'] = {'username': 'whatever'} # Override instance initial
super().__init__(*args, **kwargs)
👤j4n7
- [Answer]-Overriding get_absolute_url from a model for the sitemap
- [Answer]-Django – can't add new value to view context
- [Answer]-Using tastypie filters with angularjs and restangular
- [Answer]-How to check object relation is populated without catching DoesNotExist
- [Answer]-Persist session data Django
Source:stackexchange.com