Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django default tables

When working with databases with Django, it automatically creates 12 default tables in the database.

enter image description here

I understand that I need dango_session for storing the session and probably django_site. But why do I need the others?

In PHP I used to store users in my own custom tables. Shouldn't I do that anymore?

like image 204
zurfyx Avatar asked Jul 09 '13 10:07

zurfyx


People also ask

What is the default database in Django?

By default, the configuration uses SQLite. If you're new to databases, or you're just interested in trying Django, this is the easiest choice. SQLite is included in Python, so you won't need to install anything else to support your database.

Does Django has its own database?

Django comes with built-in database backends. You may subclass an existing database backends to modify its behavior, features, or configuration. You can see the current list of database engines by looking in django/db/backends.

Does Django create tables?

Django made creating the tables in the database very simple with its built-in ORM. To create table in the database with django is to create a django model with all required fields and then create migrations and apply them.


1 Answers

The tables are created because you have django.contrib.auth, django.contrib.sessions, and so on in your INSTALLED_APPS setting. You shouldn't delete the tables if the apps are installed, as Django will expect them to exist.

None of the contrib apps are required to run Django. However, I highly recommend that you use the Django auth and sessions app instead of writing your own. For example, if you use the auth app, you don't need to worry about how to hash passwords, and there are lots of helpful views included to log users in, reset passwords and so on.

like image 172
Alasdair Avatar answered Sep 30 '22 18:09

Alasdair