I output in the template:
{{user.first_name}}
Last name is displayed normally. What can be done so that the first name is not in a tuple, but just a string?
CodePudding user response:
Your problem seems to be an easy fix, there is a comma at the end of user.first_name = self.cleaned_data['first_name'],
, and Django is treating this as a tuple.
Your forms.py
should look like this:
class CustomSignupForm(forms.Form):
first_name = forms.CharField(max_length=30, label="first_name", strip=True, widget=forms.TextInput(attrs={'placeholder': "name", }))
last_name = forms.CharField(max_length=30, label='last_name', strip=True, widget=forms.TextInput(attrs={'placeholder': 'last_name',}))
def signup(self, request, user):
user.first_name = self.cleaned_data['first_name'] # just removed the comma :)
user.last_name = self.cleaned_data['last_name']
user.save()
return user
CodePudding user response:
You have a comma at the end of your user.first_name = self.cleaned_data['first_name'],
Remove the comma and it should fix your issue.