Error when removing/unregistering Groups: "django.contrib.admin.sites.NotRegistered: The model Group is not registered"
Context:
I already had written some Django code for an app I'm building, but decided to follow this tutorial along and when I was trying to remove the Groups table from the Admin page, I stumbled upon this error: django.contrib.admin.sites.NotRegistered: The model Group is not registered and an initial Google search did not help quite well, but a search in SO's Django tag page lead me to this answer and everything was solved.
I tried creating a new Django project and replicating the steps of the tutorial above but still got the same error.
Note:
I'm posting this question for completeness/more documentation. The error itself does not have a specific question asked about it, but there are answers if you look just one step further for it: Answer 1 & Answer 2. However, the answers are lacking depth so I'm hoping to provide some additional value by answering this question with more depth. If not appropriate, please feel free to comment and I'll remove.
I solved it by changing the order of the INSTALLED_APPS list in project/settings.py. I'm used to putting my apps config on top of the list, so I moved the apps to the end of the list, like so:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
...
'app.apps.AppConfig',
]
What I think happened is that django.contrib.auth needs the User and Group model first to setup the initial app, and then you can register and unregister models relating to django.contrib.auth.