Home > Net >  Use django admin panel without auth application
Use django admin panel without auth application

Time:09-10

I've disabled authentication for Django admin panel as described here.
I would like to go further and completely skip django.contrib.auth migrations like users or groups tables.

I've tried to remove django.contrib.auth from INSTALLED_APP and then I got error like below:

RuntimeError: Model class django.contrib.auth.models.Permission doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

Is there any way to use Django admin panel without migrating django.contrib.auth migrations?

CodePudding user response:

Short answer : No

Long answer : From a security standpoint there is absolutely no reason to ever do that, you will make your database open to everyone, with personal information.

Fortunately Django is smart enough to not let anyone do that and the requirements for the administration requires the auth middleware and the django.contrib.auth dependencies.

Again, you should not do that, you could tweak the Django framework and that could work, but you will need to write a lot of boilerplate and most package won't work.

If you want to update your authentication backend Django make it pretty easy to do so : https://docs.djangoproject.com/en/4.1/topics/auth/customizing/

But be aware that would still need at least one auth backend for the admin to work.

CodePudding user response:

django admin (django.contrib.admin) is tightly coupled with django.contrib.auth. I didn't find a way to use use admin panel without auth app.

Nevertheless, I've found a solution, which met my expectations. I've set has_permission attribute of admin.site to True, as described here.
Next, I've unregistered Group and User models from admin panel as described here. It's not clean solution, since django.contrib.auth migrations are still run, but normal user will not notice.

  • Related