A project refers to the entire application and all its parts.
An app refers to a submodule of the project. It’s self-sufficient and not intertwined with the other apps in the project such that, in theory, you could pick it up and plop it down into another project without any modification. An app typically has its own models.py (which might actually be empty). You might think of it as a standalone python module. A simple project might only have one app.
Lets understand Project and App in Django with this realistic example:
Say you are building an online shopping site (e-commerce site) in Django:
Its simply name of your website. Django will create a python package and give it a name that you have provided. lets say we name it my_shopping_site.
You can create a project in Django with this command
python manage.py startproject my_shopping_site
This will create
my_shopping_site directory in your working directory and the structure will look like this:
my_shopping_site/ # package
__init__.py # indication of package
settings.py # module 1
urls.py # module 2
wsgi.py # module 3
It’s those little components that together make up your project. They are the features of your project. In our case (shopping site) it would be:
- Cart :- Which would have a logic for user selected items for purchase.
- Products :- Which would have a logic for products that the site is selling.
- Profile:- Which would have a logic for user information.
and you can create these apps with these commands:
python manage.py startapp cart
python manage.py startapp products
python manage.py startapp profile
The structure would look like this:
my_shopping_site/ # project name
products/ # app 1
cart/ # app 2
profile/ # app 3
each app focus on a single logical piece of your project.