Django¶
Avertissement
Lors du développement, Docker doit être actif et une instance de développement doit être active (voir section dédiée).
Create a new app¶
mkdir apps/new-app
docker-compose exec web python manage.py startapp new-app apps/new-app
Add in settings.py file in INSTALLED_APPS.
Composition of a Django application¶
A Django application is mainly composed:
A
view.py
file which will be the functions that will allow to send data to web pagesTemplate files: which will receive data and display them. These files are in HTML format
A
urls.py
file which gathers all the addresses of the application to make the templates accessible from a web browserA
tests.py
file to write all the unit and functional test functionsA
models.py
file which contains the definition of the database tables (which will be translated into SQL in our case)An
admins.py
file to add a data table in the Django administration page
Make migrations in database¶
docker-compose exec web python manage.py makemigrations
docker-compose exec web python manage.py migrate