Create project §
NB: do git add .
and initial commit after removing secrets from settings.py
!
Change basic project settings §
Use env vars for settings §
Set template paths, etc. §
Create CustomUser model §
See “Django for Professionals” page 55.
NB: add GitHub link to my demo project, too.
After creating CustomUser, we can safely do the initial migration!
Initial Migrations §
Don’t forget to add all migrations to git!
Add superuser §
Add model, view, url §
Add static files folder §
File Uploads §
Upload and process files §
Add tests §
Internationalisation and Localisation §
i18n
- Internationalisation
L10n
- Localisation
Poedit Translation Editor - Poedit
Poedit Full gettext support.
https://poedit.net/
Интернационализация административной панели §
Caching §
View caching §
https://docs.djangoproject.com/en/4.1/topics/cache/#specifying-per-view-cache-in-the-urlconf
Template fragment caching §
https://docs.djangoproject.com/en/4.1/topics/cache/#template-fragment-caching
Low-level caching §
https://stackoverflow.com/questions/40772832/caching-results-of-a-django-function-call-with-cache-get-or-set
New Deployment §
Migrations §
https://realpython.com/django-migrations-a-primer/
Next workflow tested for ‘clean’ DB setup:
- remove
migrations
directories with all files from apps;
- run
makemigrations
for each app:
- run
migrate
, createsuperuser
:
New DB will be created, along with migrations
dirs in app dirs, and 0001_initial.py
files there.
- use
showmigrations
to check which migrations were applied to DB:
Nginx §
Readme: GitHub - hazadus/django-website: Basic Django website. For learning purposes. Demo: http://85.193.89.177/
Nginx need + x to all dirs along the path to static, media dirs.
View nginx logs:
Collect static §
Copy files §
Docker §
Docker compose with Django 4, Celery, Redis and Postgres
Deploying Django application that is using Celery and Redis might be challenging.
https://saasitive.com/tutorial/django-celery-redis-postgres-docker-compose/?utm_campaign=Django%2BNewsletter&utm_medium=email&utm_source=Django_Newsletter_157
Back up and restore Postgres DB data:
Email – setup and test §
Complete script – rebuild and run containers §
After collectstatic
copy files from project staticfiles dir to /home/hazadus/django-static/
Load testing §
GitHub - rakyll/hey: HTTP load generator, ApacheBench (ab) replacement
hey is a tiny program that sends some load to a web application.
https://github.com/rakyll/hey
Getting started - Locust 2.13.1 documentation
A Locust test is essentially a Python program.
https://docs.locust.io/en/stable/quickstart.html
Backup via rsync §
📂 Django | Последнее изменение: 07.02.2024 15:04