如何在Django表单中设置表单项的顺序?

时间:2018-10-27 07:08:24

标签: python django django-forms

我想在Django表单中设置自己的表单顺序,但是当我运行我的应用程序时,每次我得到一个新的表单顺序。这是代码:

from django.contrib.auth import get_user_model
from django.contrib.auth.forms import UserCreationForm
from django import forms

class UserCreateForm(UserCreationForm):

class Meta():
    fields =['username', 'email', 'password1', 'password2']
    model = get_user_model()
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)
    self.fields["password1"].label = "Your Password"
    self.fields["password2"].label = "Repeat Your Password"

用户模型为:

from django.db import models
from django.contrib.auth.models import User, PermissionsMixin
# Create your models here.

class UserModel(User,PermissionsMixin):
    def __str__(self):
         return "@{}".format(self.username)

在这种情况下我该怎么办? 预先感谢

1 个答案:

答案 0 :(得分:0)

我只是这样做,它对我有用:

const routes: Routes = [
    {
        path: 'settings',
        loadChildren: 'app/setting/setting.module.ts#SettingsModule'
    }
];