diff options
Diffstat (limited to '')
-rw-r--r-- | dotfiles/cheat/django | 50 | ||||
-rw-r--r-- | dotfiles/cheat/django-cms | 9 | ||||
-rw-r--r-- | dotfiles/cheat/django-oscar | 17 | ||||
-rw-r--r-- | dotfiles/cheat/djangocms | 29 |
4 files changed, 105 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 :) diff --git a/dotfiles/cheat/django-cms b/dotfiles/cheat/django-cms new file mode 100644 index 0000000..72770b6 --- /dev/null +++ b/dotfiles/cheat/django-cms @@ -0,0 +1,9 @@ +# dep +- python3-dev +- virtualenvwrapper + +mkvirtualenv --python=/usr/bin/python3 oscar + +pip install djangocms-installer + +python manage.py runserver 0.0.0.0:8000 diff --git a/dotfiles/cheat/django-oscar b/dotfiles/cheat/django-oscar new file mode 100644 index 0000000..a4e00cd --- /dev/null +++ b/dotfiles/cheat/django-oscar @@ -0,0 +1,17 @@ +#Dep for stretch: +- libpq-dev +- python3-dev + +# for mkvirtualenv +- virtualenvwrapper + +# DONT FORGET DO UPGRADE PIP !!!! +pip3 install -U setuptools pip + +mkvirtualenv --python=/usr/bin/python3 oscar + +# for pillow +- libjpeg-dev +pip3 install pillow + +sandbox/manage.py runserver 0.0.0.0:8000 diff --git a/dotfiles/cheat/djangocms b/dotfiles/cheat/djangocms new file mode 100644 index 0000000..76c0826 --- /dev/null +++ b/dotfiles/cheat/djangocms @@ -0,0 +1,29 @@ +# Apphook theme integration + +This is maybe not the best way to do this but it's work. + +First doc is here : http://docs.django-cms.org/en/latest/introduction/05-apphooks.html + +(`.` is the root of the django-cms project) +(`myApp` is the django app to be ingreted to django-cms) + +Create another django app specialy for integrate the wanted django app. +(ex: `./myApp_cms_integration/`) + +For apply the theme you need, in the cms app create a folder, to create a +`templates` folder for the integrated django app. +(ex: `./myApp_cms_integration/templates/myApp/`) + +Copy the base.html template of myApp django app and modify the file with this +code: + +``` +{% extends "base.html" %} + +{% block apps %} +# Here come all the code from the base.html of myApp (In this example) +{% endblock %} +``` + +You also need to add somewhere in the template of the django-cms project +`{% block apps %}{% endblock %}`. |