A Django project can contain multiple apps. These apps don’t represent the entire application. Rather, they are small functional areas of our Django project.
For example, imagine you want to build a website like Edpresso. Edpresso is a very big website that has many different functions. Instead of implementing all these functions inside a Django project, we divide this project into small functional areas that are focused on one concern. We can create functional areas like drafts, submitted shots, published shots, etc. All of these functions are completely different functional areas. The functions we have for managing the drafts are completely different from the functions we have for managing submitted shots.
So with this analogy, we divide the Django project into multiple Django apps, with each app focused on one functional area.
The beauty of these apps is that you can reuse them across different Django projects because each app is essentially a Python package.
|Django project||Django app|
|The entire application and all its parts or simply the whole website.||A small functional area of our Django project.|
|Contains all the necessary tools required for a website.||Completely different functional areas for a Django project.|
|A single Django project contains multiple apps in it.||Multiple Django apps are created in a single project.|
To learn how to create a Django project, check out this shot: How to create a Django project.
Now that we have successfully created a Django project, let’s create three apps:
Starting with the first app we want to create,
shots, key in the following command on your terminal window.
python manage.py startapp shots
Python has a utility program,
manage.py, that manages each app of a Django project. In the above command, we ask it to create an app called
Type the following command on a new terminal window to create an app called
python manage.py startapp submitted
Enter the command below on a new terminal window to create the app called
python manage.py startapp published
Note: When you create a name for a Django app using the
manage.pyutility, the name will also be used as the application directory name.
Back in your Folders, locate the previous project created. There, you will find the apps you just created. Each of the apps should contain the following subfolders:
These subfolders are what make up a typical Django app. If you find these subfolders inside the apps you just created, it means that your codes were successfully executed.
View all Courses