################################################### Common operations ################################################### Here is a first list of useful ressources to manage Django Activate virtual env ====================================================== To use Django command line, activate the virtual environement .. code-block:: bash usr1@server:~/myprojectdir$ source myprojectenv/bin/activate The prompt is changed as follows .. code-block:: bash (myprojectenv) usr1@server:~/myprojectdir$ Execute the build of the project ====================================================== Once the configuration has been done execute .. code-block:: bash (myprojectenv) usr1@server:~/myprojectdir$ python3 manage.py migrate Restart Gunicorn to apply the changes ====================================================== .. code-block:: bash (myprojectenv) usr1@server:~/myprojectdir$ sudo systemctl restart gunicorn .. _add_pages_to_django_app: Add pages to Django app ====================================================== Copy the ``*.html`` page into ``doc1/templates`` directory. .. code-block:: bash manage.py myproject myprojectenv static demo1 ├── admin.py ├── apps.py ├── migration ├── models.py ├── tests.py ├── views.py ├── templates ├── demo1 ├── index.html ├── new_page.html Edit ``new_page.html`` to add the line ``{% load static %}`` at the begining of the file .. code-block:: html {% load static %} . . Edit ``demo1/urls.py`` to declare the new page .. code-block:: python # config/urls.py from django.urls import path, include # Import this function from . import views app_name = "demo1" urlpatterns = [ # Main app path('', views.index, name="index"), path('index.html', views.index, name="index"), path('1_how_to_sphinx.html', views.how_to_sphinx, name="How to sphinx"), ] Edit ``demo1/views.py`` to create the view for the new page .. code-block:: python from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import get_object_or_404, render from django.template import loader from django.urls import reverse from django.views import generic def index(request): return render (request, 'demo1/index.html', {}) def how_to_sphinx(request): return render (request, 'demo1/1_how_to_sphinx.html', {})