Is it possible to transfer the default group model from the "Authentication and Authorization" section (on the Django admin site) to a custom one and how to do it?
Let them start from the beginning in other words.
My Django project has very simple accounts applications.
File
models.py looks like this:
from django.contrib.auth.models import AbstractUser class User(AbstractUser): def __str__(self): return self.email
file serializers.py:
from rest_framework import serializers from django.contrib.auth.models import Group from django.contrib.auth import get_user_model class GroupSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Group class UserSerializer(serializers.HyperlinkedModelSerializer): groups = serializers.HyperlinkedRelatedField( many=True, required=False, read_only=True, view_name="group-detail" ) class Meta: model = get_user_model() exclude = ('user_permissions',)
Now on the administrative site there are two sections: “Accounts” and “Authentication and authorization”. The Accounts section contains my Users table (for the user model) and the Authentication and Authorization section contains the Groups table (for the default Django group authorization model).
My question is: is it possible and how to move the table (model) to the "Accounts" section?
I even tried to create a custom “Group” model based on the default auth Group model of Django, but was stuck with migration exceptions.
source share