Contenido del Curso
Django: Build Your First Website
Django: Build Your First Website
Django Applications
Project and Applications
Let's move on to creating apps for our project. Speaking of the project itself, it is a web application, but the apps created within the Django project are like modules that will be used in our application.
Distributing server logic into separate apps allows us to organize the server functionality logically. For example, we can have a app dedicated to the user account system for an online store, and a separate app for handling information about products, their descriptions, and prices. As a result, it will be very convenient to read the server's functionality, fix bugs, and simply monitor the server's behavior.
Create a new Application
Start app via terminal. To start (create) new app in Django project, you should use the following command in the terminal:
If the command above doesn't work, try inputting this python3 manage.py startapp main
.
When you run python manage.py startapp main
, Django will create a new directory named main
within your project's directory. This directory will contain the necessary files and folders to structure your new app.
Connect App to Project
Find the file settings.py
in the main project directory (main project core) that was named when you run the django-admin startproject
command.
- For the example, the project named
main
. In themain
folder you should find thesettings.py
; - Open the
settings.py
and add your app name to theINSTALLED_APPS
list:
Now, the main
app is connected to the the Django project.
¡Gracias por tus comentarios!