From e0c0d4b38cde20e2300e86b69414dd9851b47456 Mon Sep 17 00:00:00 2001 From: neodarz Date: Thu, 5 Sep 2019 07:05:07 +0200 Subject: ooo --- dotfiles/cheat/django | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dotfiles/cheat/django (limited to 'dotfiles/cheat/django') 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.*)$', serve,{'document_root': settings.MEDIA_ROOT}), +url(r'^static/(?P.*)$', serve,{'document_root': settings.STATIC_ROOT}), +``` + +and both static and media files were accesible when DEBUG=FALSE. +Hope it helps :) -- cgit v1.2.1