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 purposes.
The parent directory mysite
is where everything will be organized. The project and 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 is 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 directory mysite
internal, in turn, is the Django project created. Since the definition in the glossary it appears that the project is a Python package (a code directory) that contains all the settings of the Django instance in question. It may also contain database settings, general application settings, and more.
The project itself doesn’t do much, because in Django’s philosophy, a project should be composed of applications (app).
The apps (app), in turn, they can be defined as a set of interrelated functionalities that are defined to create or maintain an aspect of the project. In general, apps are set to be as reusable as possible, being tasked with only one very specific function. It is also considered that apps will be, at most, independent of each other - being dependent only when it really makes sense.
For example, if your application (project) will need a Blog area, you will create an app for it, but for JUST 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, ok, but do it in another app. Don’t have a user management system? Another app. In other words (which are almost the same), apps are responsible for denigrating the application/project aspects and can be reused in as many projects as needed.
Briefly, the project is responsible for configuring the instance of Django in question according to the needs of the application and has a set of apps that define the aspects of the application.
Remember that Django is a Python package installed on the server, so it is the same code being executed by the various websites that may be hosted on it, so it is said about the instance django.
Rebound, here, that in my view the best translation for the term app is application and not application, as this is usually used to refer to the set as a whole, while application expresses a less generalist idea.
I have the small impression that something has changed, because I don’t remember the time I used to touch Django to have the script
apps.py
inside the project folder...– Wallace Maxters