Creating and linking an app
Creating an App
First, we need to create an app. In this case, we want to create an app that's going to hold the code for our database.
We create an app by running the following command:
python manage.py startapp <APP_NAME>
We're going to call our app database
, so we'll run the following command in out terminal:
python manage.py startapp database
You'll now see that there's a new directory (folder) called database
.
Linking an App
Next, we want to tell Django that we've added a new app. Just like before, we go into settings.py and changed the INSTALLED_APPS
variable. We want to all 'database'
to the list, as shown below:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'database'
]