Django is definitely not the only thing I use Python for, but I use and teach Django quite often. In the first half of 2023, I held 3 Django-related trainings, did some Django consulting, and I worked on the Python Morsels web app, which is written in Django.
My Django students and clients often ask questions that make me realize I have Django opinion that might be of interest to someone else (a fact that's challenging to recognize in isolation)!
So for the month of June I decided to post daily-ish social media threads (to both Mastodon and Twitter) on interesting Django-related ideas using the tag #DjangoJune
.
Here's a summary of the couple dozen Django tips from this #DjangoJune
adventure, including links to the Mastodon threads and occasional links to the Twitter threads (when discussion on Twitter was sufficiently different).
/admin/
is often visited by bots trying to break into Django admin siteslist_select_related
, raw_id_fields
, annotationsdjango.db.connection.queries
)query
attribute to a string)select_related
and prefetch_related
No, you don't need to completely avoid business logic in your models module. In fact I recommend that you:
But isn't dumping lots of logic in models unwieldy? What about service layers?
F
objects directly to model attributes: this can help avoid race conditions on database savesTim Schilling also shared a new explainer on Django migrations earlier this month using the Django June hashtag.
I rarely focus so heavily on publicly teaching Django; my usual focus is teaching core Python skills.
If you'd like to follow my Python musings, I recommend subscribing to my weekly tips. I send one share 3-paragraph-ish Python tip every Wednesday morning to my mailing list. If you don't do emails, you can find me sharing Python ponderings on YouTube, Mastodon, Twitter, and LinkedIn.
If you're interested in deepening your Python skills in a very hands-on way, try Python Morsels.
Need to fill-in gaps in your Python skills?
Sign up for my Python newsletter where I share one of my favorite Python tips every week.
Need to fill-in gaps in your Python skills? I send weekly emails designed to do just that.