[Django]-What is difference between users_user_permissions and auth_permission and auth_group_permissions?

6đź‘Ť

âś…

Django’s scheme for automatically generating table names is explained here. Basically, it uses the pattern app_model. In the case of ManyToManyFields—which are implemented by creating a new table to hold the relationship—this becomes app_model1_model2s.

So:

auth_permission is the table that represents the auth.Permission model.

auth_group_permissions is the table that represents the ManyToMany relationship between auth.Group and auth.Permission.

users_user_permissions is the table that represents the ManyToManyField between users.User and auth.Permission. (I assume this is coming from an app you’re using? Django’s contrib.auth version should be auth_user_user_permissions.)

See the documentation for how these tables are actually used.

Leave a comment