please help change the order of the form fields on the screen.
I created the following model:
class UserProfile(User):
status = models.CharField(
max_length=30,
blank=True,
)
address = models.EmailField(
max_length=50,
blank=True,
)
objects = UserManager()
then combined field of this model built with fields of the registration form:
class MyRegistrationForm(UserCreationForm):
username = forms.CharField(
label='username',
help_text='',
required=True,
)
password1 = forms.CharField(
label='pass1',
help_text='',
required=True,
)
password2 = forms.CharField(
label='pass2',
help_text='',
required=True,
)
class Meta:
model = UserProfile
fields = ('status', 'address')
as a result the user sees on the display field in this order: status, address, username, pass1, pass2
but I need the user to see the screen fields in the following order: username, address, pass1, pass2, status
According to the documentation :
The generated Form class will have a form field for every model field specified, in the order specified in the
fields
attribute.
class MyRegistrationForm(UserCreationForm):
...
class Meta:
model = UserProfile
fields = ('username', 'address', 'password1', 'password2', 'status')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.