aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/cheat/django
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-09-05 07:05:07 +0200
committerneodarz <neodarz@neodarz.net>2019-09-05 07:05:07 +0200
commite0c0d4b38cde20e2300e86b69414dd9851b47456 (patch)
tree5df65243447352a9637d1f783247bfd5ccff2ef4 /dotfiles/cheat/django
parentdc45bf89a66ec6c8cd25cf5605deb853f6984705 (diff)
downloaddotfiles_dotdrop-e0c0d4b38cde20e2300e86b69414dd9851b47456.zip
dotfiles_dotdrop-e0c0d4b38cde20e2300e86b69414dd9851b47456.tar.xz
ooo
Diffstat (limited to 'dotfiles/cheat/django')
-rw-r--r--dotfiles/cheat/django50
1 files changed, 50 insertions, 0 deletions
diff --git a/dotfiles/cheat/django b/dotfiles/cheat/django
new file mode 100644
index 0000000..97efafc
--- /dev/null
+++ b/dotfiles/cheat/django
@@ -0,0 +1,50 @@
+# Make a migration
+change model in models.py
+python manage.py makemigrations
+python manage.py migrate
+
+#Django source code
+python -c "import django; print(django.__path__)"
+
+# Enable virtual env:
+mkvirtualenv --python=/usr/bin/python3 oscar
+
+# Don't forget to install
+pip install django
+
+# Run dev server
+python manage.py runserver 127.0.0.1:8000
+
+# tinymce for django
+https://github.com/romanvm/django-tinymce4-lite
+
+# For create a .po file for translation
+# first create a locale folder in module folder or edit LOCALE_PATH in conf file
+
+# run command for generate the file
+django-admin makemessages -l fr
+
+# update the file if there are new translation
+django-admin makemessages -l fr
+
+# compil translations files
+django-admin compilemessages
+
+# Pour tester avec debug=False et manage.py runserver
+source : https://stackoverflow.com/a/49722734
+
+In urls.py I added this line:
+
+```
+from django.views.static import serve
+```
+
+add those two urls in urlpatterns:
+
+```
+url(r'^media/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),
+url(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}),
+```
+
+and both static and media files were accesible when DEBUG=FALSE.
+Hope it helps :)