2

I've created a custom user model as described in 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)

all works fine, but now Users and Groups are in different applications in admin: separate applications

Is it possible to put custom user model and Groups in one application?

Mariusz Jamro
  • 30,615
  • 24
  • 120
  • 162
Digital God
  • 471
  • 1
  • 5
  • 17

0 Answers0