JAEMYUN IS GRANDPA JAEMYUN IS GRANDPA - 2 months ago 9
Python Question

How does Django make tables relating to user,auth,group,session and so on with very first migration?

I am little bit exciting to write my question in here. Normally I searched other questions to figure out my own problem. By the way, this time I couldn't figure out my question by searching it. That's why I am leaving question in here in person.

My question is :

How does Django framework make initial tables?
if you make Django project and then migrate. it makes tables like below. even thought you didn't make any apps in project or didn't write any code in models.py of each app.

auth_group

auth_group_permissions
auth_permission

auth_user

auth_user_groups

auth_user_user_permissions

django_admin_log

django_content_type

django_migrations

django_session

I understood what ORM, MTV, migrations are. I hope I can understand Django framework more deeply and want to figure what hidden code(or Django structure) in Django made those initial tables.

Addition Question :

I understood that I can control default permissions or custom permission in Meta class. if I don't set any, it makes three dafault permssions(add,change,delete).

when I migrate as I told you above, I can check those in a table named 'auth_permission'. There are records which is made initially

1;"Can add log entry";1;"add_logentry"
2;"Can change log entry";1;"change_logentry"
3;"Can delete log entry";1;"delete_logentry"
4;"Can add permission";2;"add_permission"
5;"Can change permission";2;"change_permission"
6;"Can delete permission";2;"delete_permission"
7;"Can add user";3;"add_user"
8;"Can change user";3;"change_user"
9;"Can delete user";3;"delete_user"
10;"Can add group";4;"add_group"
11;"Can change group";4;"change_group"
12;"Can delete group";4;"delete_group"
13;"Can add content type";5;"add_contenttype"
14;"Can change content type";5;"change_contenttype"
15;"Can delete content type";5;"delete_contenttype"
16;"Can add session";6;"add_session"
17;"Can change session";6;"change_session"
18;"Can delete session";6;"delete_session"

How can I manipulate those? ex)what if I want to change those code name or what if I don't want to make default permissions(add,change,delete)?

Thank you in advance.
if my explanation for my question was not clear, please leave me comment.
Have a nice day!

Answer

There are apps that are included in the project by default. You can see this is the INSTALLED_APPS in the settings.py file of your project. auth_group is a table from django.contrib.auth.