First, let's look at the directory structure that is generated when we create a project:
mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
Project created with the command django-admin startproject mysite
, for information.
-
The parent directory mysite
is where everything will be organized. The project and the applications will be organized in this directory. At first, it is common for the developer to believe that this is the Django project created, but no, it's just a directory to separate everything from the rest of the files on the machine. So much so that the name of this directory is not important - it only takes the same project name by default.
-
The internal mysite
directory, in turn, is the Django project created. Since the definition in the glossary states that the project is a Python package (a code directory) that contains all the settings of the Django instance in question. It can also contain database settings, general application settings, and more.
The project itself does not do much because, in Django's philosophy, a project should be composed of applications.
apps , in turn, can be defined as a set of interrelated features that are defined to create or maintain an aspect of the project. In general, apps are set to be as reusable as possible, and are charged with only a very specific function. It is also considered that the apps will be, to the maximum, independent of each other - being dependent only when it really makes sense.
For example, if your application (project) will need a Blog area, you'll create an app for it, but for ONLY that. In this app you will define all necessary database table structures and all business rules for a blog to be functional.
But I want to create an access management system for users on my blog , okay, but do it in another app. Do not have a user management system? Another app. In other words (which are almost the same), apps are responsible for denying aspects of the application / project and can be reused in as many projects as needed.
In short, the project is responsible for configuring the Django instance in question according to the needs of the application and has a set of apps that define aspects of it.
Remember that Django is a Python package installed on the server, so it's the same code being run by the various sites that may be hosted on it, so it says about the instance of the Django.
I emphasize here that in my view the best translation for the term app is application and not application, as this is normally used to refer to the whole set, while application expresses a idea less generalist.