django 1.5自定义用户 - 管理员中的单独应用程序

时间:2013-08-06 12:04:03

标签: django model django-custom-user

我已按docs

中所述创建了自定义用户模型

models.py

class Account(AbstractUser):
    middle_name = models.CharField(_('middle name'), max_length=30, blank=True)
    is_partner  = models.BooleanField(_('partner status'), default=False,
        help_text=_('Designates whether the user is partner or employee'))

forms.py

class AccountChangeForm(UserChangeForm):
    class Meta:
        model = Account

class AccountCreationForm(UserCreationForm):
    class Meta:
        model = Account

admin.py

class AccountAdmin(UserAdmin):
    form = AccountChangeForm
    add_form = AccountCreationForm
    fieldsets = (
        (None, {'fields': ('username', 'password')}),
        (_('Personal info'), {'fields': ('first_name', 'middle_name', 'last_name', 'email')}),
        (_('Permissions'), {'fields': ('is_active', 'is_partner', 'is_staff', 'is_superuser',
                                       'groups', 'user_permissions')}),
        (_('Important dates'), {'fields': ('last_login', 'date_joined')}),
    )

admin.site.register(Account, AccountAdmin)

一切正常,但现在用户和组在管理员的不同应用程序中: separate applications

是否可以将自定义用户模型和组放在一个应用程序中?

0 个答案:

没有答案