Join my Laravel for REST API's course on Udemy πŸ‘€

Create a new app in a Django project

October 19, 2020  ‐ 1Β min read

To create a new app in Django we utilize the startapp command. This creates a Django app directory with a specified app name.

The app is created in by going in the root folder of your Django project and run the following command. The root folder is where the manage.py file is by the way.

$ python manage.py startapp plebapp

This results in a new directory being created named plebapp with the file structure as shown below.

$ tree plebapp
plebapp
β”œβ”€β”€ admin.py
β”œβ”€β”€ apps.py
β”œβ”€β”€ __init__.py
β”œβ”€β”€ migrations
β”‚Β Β  └── __init__.py
β”œβ”€β”€ models.py
β”œβ”€β”€ tests.py
└── views.py

In order to use this app we are almost set. To actually include the app in our projects it has to be added to INSTALLED_APPS in the settings. You can reference the new app by its name.

INSTALLED_APPS = [
    ...
    'plebapp',
]

Or by referencing the Config class you find in ./plebapp/apps.py.

INSTALLED_APPS = [
    ...
    'plebapp.apps.PlebappConfig',
]