1👍
✅
Override save
method in SignUpForm
def save(self, commit=True):
instance = super(SignUpForm, self).save(commit=False)
instance.username = "%s.%s" %(self.cleaned_data['first_name'], self.cleaned_data['last_name'])
if commit:
instance.save()
return instance
0👍
You could try something like:
my_data = dict(request.POST.iterlists())
my_data['username'] = my_data['firstname'] + '.' + my_data['lastname']
form = SignUpForm(my_data)
if form.is_valid():
form.save()
...
- Navigation links not working in navbar (Bootstrap)(Django)
- Query Django Wagtail Document Model
- How can I use two functions of the same name in model django
Source:stackexchange.com