Background Image
Table of Contents Table of Contents
Previous Page  100 / 478 Next Page
Information
Show Menu
Previous Page 100 / 478 Next Page
Page Background

I hear you ask? Because Django creates a special

test database

for unit tests; it’s one of

the magical things that Django’s

TestCase

does.

To set up our “real” database, we need to create it. SQLite databases are just a file on

disk, and you’ll see in

settings.py

that Django, by default, will just put it in a file called

db.sqlite3

in the base project directory:

superlists/settings.py.

[

...

]

# Database

#

https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES

=

{

'default'

: {

'ENGINE'

:

'django.db.backends.sqlite3'

,

'NAME'

:

os

.

path

.

join

(

BASE_DIR

,

'db.sqlite3'

),

}

}

We’ve toldDjango everything it needs to create the database, first via

models.py

and then

when we created the migrations file. To actually apply it to creating a real database, we

use another Django Swiss Army knife

manage.py

command,

migrate

:

$

python3 manage.py migrate

Operations to perform:

Synchronize unmigrated apps: contenttypes, sessions, admin, auth

Apply all migrations: lists

Synchronizing apps without migrations:

Creating tables...

Creating table django_admin_log

Creating table auth_permission

Creating table auth_group_permissions

Creating table auth_group

Creating table auth_user_groups

Creating table auth_user_user_permissions

Creating table auth_user

Creating table django_content_type

Creating table django_session

Installing custom SQL...

Installing indexes...

Running migrations:

Applying lists.0001_initial... OK

Applying lists.0002_item_text... OK

You have installed Django's auth system, and don't have any superusers defined.

Would you like to create one now? (yes/no):

no

72

|

Chapter 5: Saving User Input