The Django web framework includes a default object-relational mapping layer (ORM) that can be used to interact with application data from various relational databases such as SQLite, PostgreSQL and MySQL.
The Django ORM has evolved over the past dozen years since it was created make sure to not only read up on the latest tutorials but also learn about newer optimizations, such as prefetch_related and select_related, that have been added throughout the project's history.
Django models, encapsulation and data integrity is a detailed article by Tom Christie on encapsulating Django models for data integrity.
Django Debug Toolbar is a powerful Django ORM database query inspection tool. Highly recommended during development to ensure you're writing reasonable query code. Django Silk is another inspection tool and has capabilities to do more than just SQL inspection.
Django QuerySet Examples (with SQL code included) teaches how QuerySets work and shows the corresponding SQL code behind the Python code you write to use the ORM.
Making a specific Django app faster is a Django performance blog post with some tips on measuring performance and optimizing based on the measured results.
Why I Hate the Django ORM is Alex Gaynor's overview of the bad designs decisions, some of which he made, while building the Django ORM.
Going Beyond Django ORM with Postgres is specific to using PostgreSQL with Django.
How to view Django ORM SQL queries along with django-sql-explorer allow you to better understand the SQL code that is generated from the Django ORM.
Migrating a Django app from MySQL to PostgreSQL is a quick look at how to move from MySQL to PostgreSQL. However, my guess is that any Django app that's been running for awhile on one relational database will require a lot more work to port over to another backend even with the power of the ORM.
Adding basic search to your Django site shows how to write generic queries that'll allow you to provide site search via the Django ORM without relying on another tool like ElasticSearch. This is great for small sites before you scale them up with a more robust search engine.
The Django ORM Cookbook provides code recipes for various ways to use the Django ORM to insert and query data.
How to use Django's Proxy Models is a solid post on a Django ORM concept that doesn't frequently get a lot of love or explanation.
Tightening Django Admin Logins shows you how to log authentication failures, create an IP addresses white list and combine fail2ban with the authentication failures list.
How to Turn Django Admin Into a Lightweight Dashboard and How to Use Grouping Sets in Django are two great posts on how to add custom features to the Django Admin as well as optimize with more advanced SQL when the first attempt at the queries get slow due to larger amounts of data.
Sorting querysets with NULLs in Django shows what to do if you're struggling with the common issue of sorting columns that contain NULL values.
Best Practices working with Django models in Python
has a ton of great advice on proper model naming conventions, quirks to
avoid with ForeignKey field relationships, handling IDs and many other
edge cases that come up when frequently working with Django's ORM.
Merging Django ORM with SQLAlchemy for Easier Data Analysis provides rationale for using the SQLAlchemy ORM instead of Django's default ORM in some situations.
Working with huge data sets in Django
explains how to slice the data you retrieve by query into pages and then
use prefetch_related on a subset of the data rather than your whole
data set.
Solving performance problems in the Django ORM
gives a slew of great code snippets to use with django.db.connection so
you can discover issues such as unexpected extra queries and problematic
key relationships.