2👍
✅
Since the save
method returns an Model object
, you can modify it again before definitively save it to the database :
if form.is_valid():
prefs = form.save(commit=False)
prefs.user = request.user
# if they logged in through social network there are other fields
if socialacc:
prefs.firstname = socialacc[0].extra_data['firstName']
...
prefs.save()
Source:stackexchange.com