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.
Answer # 1
Writing js code that uses the bi-directional binding as in Vue.js to enter the same thing in the nickname field with the username input, or allow empty input with nickname and submit in an empty state I think there is a way to set the same nickname as username on the Python side.
[Vue.js bidirectional binding demo]
https://jp.vuejs.org/v2/guide/index.html#%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E5%85%A5%E5 % 8A% 9B% E3% 81% AE% E5% 88% B6% E5% BE% A1
- python - about image deletion in django
- python - i want to save the default data if the column is null in django
- python 3x - i have a question about pipenv i want to set the directory location
- python - i have a question about multiple updates of pymongo
- i have a question about runtime errors and exception handling in python
- python - about formal parameters in the definition
- about instantiation with qpushbutton in python qt produces the same thing
- python - about matplotlib graph fill
- about python tkinter
- python - django how to receive multiple checkbox values
- python - about input error
- python - i get an argument must be int or float error in django
- python - [django] read csv file from url
- python - about the specified position of pop ()
- python - about function calls
- about cooperation of python csv spreadsheet
- python: about variable references
- about auxiliary lines and axis scales of python heatmap
- i have a question about html css
- python - about the presence or absence of () after print
- python - vscode: i can't debug django apps
- python - when will you start the startapp in django?
- python - exception value erorr catch location
- python - i don't know what's wrong with an error in serialize on the django rest framework
- python - django form i want to write a little smarter
- python - if you create multiple signup screens with django, you want to change the redirect destination in case of an error
- i want to create polygon data in python geojson format
- python - can't get json from url
- python - when i set the uuid field in django, i get field'object_id' expected a number but got '78a0767cb607488087a73f17565bb