Vous n'êtes pas identifié(e).
L'icône rouge permet de télécharger chaque page du wiki visitée au format PDF et la grise au format ODT →
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente | Prochaine révision Les deux révisions suivantes | ||
utilisateurs:hypathie:tutos:developpement-pyhon-utiliser-django [08/12/2015 14:23] Hypathie [Avant de commencer] |
utilisateurs:hypathie:tutos:developpement-pyhon-utiliser-django [08/12/2015 14:41] Hypathie [Configurations et installation de Django avec SQLite3] |
||
---|---|---|---|
Ligne 67: | Ligne 67: | ||
- | ===== Configurations et installation de Django avec SQLite3===== | + | ===== Créer des projets Django en python2 ou python3===== |
+ | |||
+ | ===Les versions de python sur sa Jessie === | ||
+ | |||
+ | <code user> ls /usr/bin/python*</code> | ||
+ | <code retour> | ||
+ | /usr/bin/python /usr/bin/python3 /usr/bin/python3-config | ||
+ | /usr/bin/python2 /usr/bin/python3.4 /usr/bin/python3m | ||
+ | /usr/bin/python2.7 /usr/bin/python3.4-config /usr/bin/python3m-config | ||
+ | /usr/bin/python2.7-config /usr/bin/python3.4m /usr/bin/python-config | ||
+ | /usr/bin/python2-config /usr/bin/python3.4m-config | ||
+ | </code> | ||
+ | |||
+ | <note tip> | ||
+ | L'idée suivie ici est de pouvoir aussi bien créer des projets Django codés en python 3 tandis que c'est la version python 2 qui est en place sur tout le système que l'inverse, c'est-à-dire, pouvoir créer des projects Django codés en python2 alors que c'est python 3 qui est mise en place sur tout le système. \\ | ||
+ | |||
+ | Pour installer Django avec python3 y compris **dans un environnement virtuel on n'utilisera pas** ''virtualenv'' seul, afin de s'éviter quelque conflits lors de l'installation de django. \\ | ||
+ | |||
+ | En effet : | ||
+ | |||
+ | <code user> | ||
+ | python --version | ||
+ | </code> | ||
+ | <code retour> | ||
+ | Python 3.4.2 | ||
+ | </code> | ||
+ | |||
+ | <code user>virtualenv MonPy3Django -p /usr/bin/python3.4</code> | ||
+ | <code user>cd MonPy3Django/</code> | ||
+ | <code user>source bin/activate 1.8-3.4</code> | ||
+ | <code retour>Downloading/unpacking django | ||
+ | Downloading Django-1.9-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded | ||
+ | Installing collected packages: django | ||
+ | *** Error compiling '/tmp/pip-build-c20d1nfa/django/django/conf/app_template/apps.py'... | ||
+ | File "/tmp/pip-build-c20d1nfa/django/django/conf/app_template/apps.py", line 4 | ||
+ | class {{ camel_case_app_name }}Config(AppConfig): | ||
+ | ^ | ||
+ | SyntaxError: invalid syntax | ||
+ | |||
+ | *** Error compiling '/tmp/pip-build-c20d1nfa/django/django/conf/app_template/models.py'... | ||
+ | File "/tmp/pip-build-c20d1nfa/django/django/conf/app_template/models.py", line 1 | ||
+ | {{ unicode_literals }}from django.db import models | ||
+ | ^ | ||
+ | SyntaxError: invalid syntax | ||
+ | |||
+ | Successfully installed django | ||
+ | Cleaning up... | ||
+ | </code> | ||
+ | |||
+ | :-/ | ||
+ | |||
+ | <code user>rm -r ~/MonPy3Django</code> | ||
+ | |||
+ | </note> | ||
==== Installer pyenv==== | ==== Installer pyenv==== | ||
Ligne 287: | Ligne 340: | ||
{{http://pix.toile-libre.org/upload/img/1449147148.png}}\\ | {{http://pix.toile-libre.org/upload/img/1449147148.png}}\\ | ||
- | ====Premier projet avec la base de données sqlite3==== | + | |
+ | =====Premier projet avec la base de données sqlite3===== | ||
* Par défaut, Django utilise la base de donnée sqlite3 : | * Par défaut, Django utilise la base de donnée sqlite3 : |