I'm using Django 2.x
I have created a custom user model by extending the AbstractModel in authentication
application
class User(AbstractUser):
pass
and updated in settings
AUTH_USER_MODEL = 'authentication.User'
This has resulted in two sections in the admin panel. One section authentication contains User model while default Authentication and Authorization contain only Group model.
I want to move either User to Authentication and Authorization or Group to Authentication so that both models could be together in a section.
For that, I have added this in the authentication.admin.py
apps.get_model('auth.Group')._meta.app_label = 'authentication'
To move Group to Authentication.
After running
python manage.py makemigrations
It generates migration in the auth
app of django
Migrations for 'auth':
/Users/anuj/.local/share/virtualenvs/originor_py-Vd6fDdN7/lib/python3.6/site-packages/django/contrib/auth/migrations/0010_auto_20190220_0238.py
- Remove field permissions from group
- Alter field groups on user
- Delete model Group
And on migrating the migrations ./manage.py migrate
, it gives error as
ValueError: The field auth.User.groups was declared with a lazy reference to 'authentication.group', but app 'authentication' doesn't provide model 'group'.
How can I move Group
model to another section in the Django admin?
Do I need to create custom Group model?