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 - i want to change the ip address that the django app gets by default from remote_addr to http_x_forwarded_for in middlew
- i have a question about runtime errors and exception handling in python
- python - [question] about combining pandas data frames
- python - about image deletion in django
- python 3x - i have a question about sleep in python
- i have a question about basic python problems
- python - i can't find some url paths after deploying django
- python - about "" "of" "" select === = "" "
- json - question about jq → i want to divide the processing according to the presence or absence of the deep key
- python - about image display and position of main ()
- python 3x - about the amount of data for object detection using machine learning
- python 3x - about functions used in python for statement
- about image output of python
- [wordpress] i have a question about hiding the article list
- python 3x - please teach about the exchange of information with qthead
- python - about x-axis adjustment in matplotlib
- python, about the fire spread step of forest fire simulation
- about the description of try except in python
- python - about hamiltonian neural networks
- python - about write loop to csv
- Error Installing Python3 MySqlClient
- python : Django gives an error: CAN Only Concatenate Str (not "NONETYPE") to str
- python : Working with the database in Django receiving data and requests
- python : NGINX, GUNICORN and UNIX sockets
- python : UTF-8 'Codec CAN't Decode Byte 0x89 In Position 0: Invalid Start Byte When opening a photo
- Python. PARTS PARTICIPATIONS After full loading (CSS, JS)
- Typeerror error: String Indices Must Be Integers, when running Python script on Heroka
- python : Not displayed list of articles through the template
- python : Typeerror: Argument of Type 'Posixpath' is not iTeable when creating a superwater
- python : Typeerror: Missing 1 Required Postal Argument: 'Search_Query'