Outils pour utilisateurs

Outils du site


django

Ceci est une ancienne révision du document !


Installation sur Ubuntu

Install Python, Pip et venv (environnement virtuel):
sudo apt install -y python3-full
sudo apt install python3-pip python3-venv -y

Créer un dossier de projet:
mkdir ~/my-django-app
cd ~/my-django-app

Créer l'environnement virtuel (nommé env dans l'exemple):
python3 -m venv env

Environnement virtuel:
source env/bin/activate - active l'environnement
deactivate - désactive

Installer Django et vérifier la version:
python -m pip install Django
django-admin –version ou python -m django –version

Commandes de bases

  • django-admin startproject mysite djangotutorial - Crée un projet appelé “mysite” dans un dossier “djangotutorial”
  • python manage.py runserver - démarre le serveur en étant dans le dossier du projet
  • python manage.py startapp polls - Crée l'application “polls” dans le projet courant
  • python manage.py migrate - Crée et migre les tables de base de donnée
  • python manage.py makemigrations polls - Prépare la création ou migration du modèle de donnée de “polls”
  • python manage.py sqlmigrate polls 0001 - Affiche le code SQL nécessaire à l'adaptation de la BDD pour polls
  • python manage.py check - Vérifie la conformité du projet sans rien modifier
  • python manage.py createsuperuser - Créer un compte d'administrateur
  • python manage.py test polls - Lancer les tests sur polls

Applications tierces

  • python -m pip install django-debug-toolbar - Installation de Debug Toolbar
django.1783265124.txt.gz · Dernière modification : de oz