Repo backing talk at Django Day CPH 2022.
Talk link here.
Set up virtual environment. And then:
pip install -r requirements.txt
The code by default talks to a postgres instance on a local Docker container. You will have to set that up yourself. Then change the variables within the connection string DATABASES
setting.
If you want to avoid setting up and just run the code against sqlite
replace the DATABASES
setting. Here's the code:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
Can be done using pizzas.tests.utils.load_data
function. This is also used to set up data for unit tests.
Run the below:
python manage.py shell_plus
In the terminal:
from pizzas.tests.utils import load_data
load_data()
python manage.py test
- Database access optimization
- Model managers
- queryset prefetch_related and select_related
- queryset conditional expressions
- queryset aggregation
- assertNumQueries
- django-extensions, for
manage.py shell_plus --print-sql
- Django Debug Toolbar
- Lindy Effect - Wikipedia
- An Expert Called Lindy by Nassim Taleb
- Tips for Using Django's ManyToManyField by Lacey Williams Henschel
- Django and the N+1 Queries Problem by Adam Johnson
- Pushing the Django ORM to its limits by Sigurd Ljødal
- PostgreSQL execution plan operations
- Five Tips For a Healthier Postgres Database in the New Year by Craig Kerstiens
- What is a "Bitmap heap scan" in a query plan?
- For framing code snippets: carbon
- For diagrams: excalidraw
Both free to use at time of writing.