[Answered ]-Removing auth_groups and auth_permission table from DB.(Django Rest Framework)

1👍

I honestly don’t see why you should drop these. If you don’t use these it will not have much impact on the rest. The amount of disk used for an empty table is extremely small, and if you don’t insert or update any records, there is also no performance bottleneck.

But even if you don’t use these models, Django does. Indeed, staff members (users with is_staff) can log in to the ModelAdmin if these are not admin, Django checks if they have the permission to see, edit and remove model objects.

If you drop these it is possible that eventually if some permission check is done, you will get database errors. Django admin for example uses these groups and permissions to check if you can edit objects.

but I can’t remove django.contrib.auth from the INSTALLED_APPS in settings.py as I’m using login, authenticate modules of contrib.auth.

If you use these for a custom model, there is no need to add django.contrib.auth to INSTALLED_APPS. These functions work then with the custom user model, but since you seem to have "hidden" the Group model, I suspect that you use the builtin. Well if you use Django’s builtin user model, then of course that ships with groups and permissions. If you use a custom user model, you can (to some extent) set the terms.

Also if I drop these two tables manually from DB will there be any effect on my project?

Yes, Django has some views that perform permission checks, not at least on the ModelAdmin, so then for non-admin users, this will raise database errors.

I have already talked to some folks they are suggesting not to drop these tables.

Manually changing the database is the worst one can do if the database is managed by another application, so that would indeed be a very bad idea.

Leave a comment