aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/cheat/django
diff options
context:
space:
mode:
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 :)