Paul R
Paul R

Reputation: 2797

What is difference between users_user_permissions and auth_permission and auth_group_permissions?

Django autogenerated above tables with syncdb, but I can't understand what are those tables for. Sorry for silly question, but I'm just started with groups and permissions.

Upvotes: 3

Views: 1752

Answers (1)

Kevin Christopher Henry
Kevin Christopher Henry

Reputation: 49012

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.

Upvotes: 6

Related Questions