Home>

If i have the following model, is there a way to set the username value to the nickname column by default when registering data from the form?

class User (models.Model):
    #Defining column names
    username = models.CharField (max_length = 10, unique = True)
    nickname = models.CharField (max_length = 10, unique = True)
class UserForm (forms.ModelForm):
    class Meta:
        model = User
        fields = ['username']

Rather than entering the nickname from the beginning, I asked if there was a way to set the default.

~ Additional ~
Sorry for not enough words.
For nickname, username is set as default, but it is assumed that the user can change it later.
In addition, it is assumed that it will not be displayed on the initial screen at the time of registration, and if there is no change, the default contents will continue to be used as they are.