Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Tailwind CSS on Python and Heroku - Building SaaS
Tailwind CSS is a fantastic tool for making CSS easy to use on your webapps. On the video, I added Tailwind CSS to my Django app and showed how to use it and deploy it to Heroku (which required some extra configuration for JavaScript support). -
Django: Defer a model field by default
Some models have one or a few large fields that dominate their per-instance size. For example, take a minimal blog post model: from django.db import models class Post(models.Model): blog = models.ForeignKey("Blog", on_delete=models.CASCADE) title = models.TextField() body = models.TextField() body is typically many times larger than the rest of the Post. It can be a good optimization to defer() such fields when not required: def index(request): posts = Post.objects.defer("body") ... Deferred fields are not fetched in the main query, but will be lazily loaded upon access. Deferring large fields can noticeably reduce data transfer, and thus query time, memory usage, and total page load time. When most usage of a model does not require the field, you might want to defer a field by default. Then you don’t need to sprinkle .defer(...) calls everywhere, and can instead use .defer(None) in the few sites where the field is used. Defer by default with a custom base manager To defer fields by default, follow these steps: Create a manager class that makes the appropriate defer() call in its get_queryset() method. Attach the manager to the model, ideally as objects. Make the manager the Model’s base manager by naming it in Meta.base_manager_name. (This manager … -
Tailwind CSS on Python and Heroku - Building SaaS
Tailwind CSS is a fantastic tool for making CSS easy to use on your webapps. On the video, I added Tailwind CSS to my Django app and showed how to use it and deploy it to Heroku (which required some extra configuration for JavaScript support). -
Database generated columns⁽³⁾: GeoDjango & PostGIS
An introduction to database generated columns, using PostgGIS, GeoDjango and the new GeneratedField added in Django 5.0. -
Test your documentation
This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction. Consider a docstring Suppose you’re writing a Python function and, as you’re supposed to do, you give it a docstring, and you even provide some examples of how the function is supposed … Read full entry -
Use unittest's subtest helper
This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction. Python testing frameworks The Python standard library ships with the unittest module for writing tests. The first thing I want to mention about it is that it gets a lot of … Read full entry -
Don't mock Python's HTTPX
This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction. Moving on from requests For quite a long time, the standard recommendation for making HTTP requests in Python was the aptly-named requests package. And you can still use requests if you … Read full entry -
WhiteNoise For Static Files - Building SaaS
This video is all about adding the popular WhiteNoise package into my Django app to serve static files (e.g., CSS, JavaScript, and images) directly from the app. I walk through the process from start to finish and deploy it live to show how things work. -
WhiteNoise For Static Files - Building SaaS
This video is all about adding the popular WhiteNoise package into my Django app to serve static files (e.g., CSS, JavaScript, and images) directly from the app. I walk through the process from start to finish and deploy it live to show how things work. -
Django News - Django 5.0 Released! - Dec 8th 2023
News Django 5.0 released The Django team is happy to announce the release of Django 5.0. The release notes cover a deluge of exciting new features in detail. djangoproject.com Django bugfix release: 4.2.8 Django 4.2.8 fixes several bugs in 4.2.7 and adds compatibility with Python 3.12. djangoproject.com Updates to Django Last week we had 23 pull requests merged into Django by 12 different contributors - including 5 first time contributors! Congratulations to Peter Thomassen, Mark Walker, KimSia Sim, Nathaniel Conroy, and Adrien for having their first commits merged into Django - welcome on board! The main update is 🥁🥁🥁 Django 5.0 is out!!! Huge congratulations to everyone who made this happen and special thank you to the Django Fellows (we couldn't do this without them). Help needed 📢 Are you a selenium expert? Introduce yourself in #contributor-discussions, we have lots of things we'd love to discuss with you! Our Croatian translation coordinator is stepping down, can you step up? Django Newsletter Wagtail CMS Wagtail 5.2.2 release notes Wagtail 5.2.2 adds support for Django 5.0 and includes a half dozen bug fixes. wagtail.org Sponsored Ad Sick of performance issues? Enter Scout's APM tool for Python apps. Easily pinpoint and fix slowdowns … -
Use "pip install" safely
This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction. Managing dependencies should be boring Last year I wrote a post about “boring” dependency management in Python, where I advocated a setup based entirely around standard Python packaging tools, in that … Read full entry -
Compile your Python
This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction. You can compile Python? Yes. And in a lot of ways! For example, you can use tools like Cython or mypyc to write Python, or Python-like code, and turn that Python-like code automatically … Read full entry -
Operations, WhiteNoise, and Tailwind - Building SaaS #177
In this episode, I worked through a couple of issues discovered after having the site be operational for real use. From there, we moved onto some fundamental technology and integrated WhiteNoise to handle static files for the application. After adding WhiteNoise, we hooked up Tailwind CSS. -
Django: Fix version 5.0’s URLField.assume_scheme warnings
Since Django’s inception, the web has gradually moved from HTTP to HTTPS, a welcome move for security. But the history has meant older parts of Django have had a lingering HTTP bias. Many of these have been migrated to default to HTTPS instead in previous versions. Django 5.0 starts the migration of another HTTP bias in forms.URLField. The old behaviour: when URLField is provided a URL without a scheme, it assumes it to be “http”: In [1]: from django import forms In [2]: forms.URLField().to_python('example.com') Out[2]: 'http://example.com' Django 5.0 has started a deprecation process to change this default to “https” (Ticket #34380). This version shows a PendingDeprecationWarning when instantiating a URLField: In [1]: from django import forms In [2]: forms.URLField().to_python('example.com') <ipython-...>:1: RemovedInDjango60Warning: The default scheme will be changed from 'http' to 'https' in Django 6.0. Pass the forms.URLField.assume_scheme argument to silence this warning. forms.URLField().to_python('example.com') Out[2]: 'http://example.com' Here’s that warning message in a more readable format: RemovedInDjango60Warning: The default scheme will be changed from 'http' to 'https' in Django 6.0. Pass the forms.URLField.assume_scheme argument to silence this warning. Django 5.1 will turn that into a DeprecationWarning and Django 6.0 will change the default and remove the warning. Here’s the related release note: … -
Operations, WhiteNoise, and Tailwind - Building SaaS with Python and Django #177
In this episode, I worked through a couple of issues discovered after having the site be operational for real use. From there, we moved onto some fundamental technology and integrated WhiteNoise to handle static files for the application. After adding WhiteNoise, we hooked up Tailwind CSS. -
Kolo for Django - Lily Foote
Kolo for Django Lily on GitHub Add Field.db_default for defining database defaults ticket and in the 5.0 release notes Add the ability to use database-level CHECK CONSTRAINTSKivy Support the ShowLearnDjango.comButtonDjango News newsletter -
How to Increase Swap File Size on a Linux Server
Note: This tip should work on most Linux-based servers, such as Ubuntu, Debian, OpenSUSE, Fedora, and CoreOS. A swap space is very handy when our server is running at the limits of its memory. Often, especially on VPS, the swap space file size is very small. You can check the … Read now -
Understanding virtual environments in Python
This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction. Linking up I want to talk today about Python virtual environments (or “venvs”), but first I need to cover a bit of background. Suppose you write a program, and it needs access … Read full entry -
Mercurial Mirror For Django 5.0 Branch
The mirror is up and running since the first beta or so, but I forgot to mention it on the blog. Now that 5.0 is officially released, it seems a perfect timing to fix that. For the record, those mirrors are read-only, and aimed at production (aka “I want an easy way to update Django […] -
Easy HTTP status codes in Python
This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar for Advent 2023, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post in the series for an introduction. The most useful test I could be misremembering, but I think Frank Wiles was the first person I ever heard explain that, for a web application, … Read full entry -
Making Decisions: First decide how to decide: “one weird trick” for easier decisions
This is my preferred decision-making process – a version of the “document-discuss-decide” process that I called for at the end of the part 1 in this series. The most important part of this process – its “one weird trick”, if you will – is the way it includes a “how shall we decide?” step. This separates out the meta-question of the decision-making process from the decision itself, which (I’ve found) makes decisions much easier. -
A Python/Django Advent calendar
Advent is the liturgical season preceding Christmas in many Christian traditions, and generally begins on a Sunday — often the fourth Sunday before Christmas Day, but it varies depending on the church and the rite, which can put the first Sunday in Advent in either late November or early December. The concept of an Advent “calendar” which counts down to Christmas, and in which each day has a door or panel which opens to reveal a … Read full entry -
Saturday stream explorer
I was looking for new thing to do to improve my stream. This is mostly me goofing off. -
Saturday stream explorer
I was looking for new thing to do to improve my stream. This is mostly me goofing off. -
Django News - 2024 DSF Board Election Results - Dec 1st 2023
News 2024 DSF Board Election Results The 2024 Django Software Foundation (DSF) Board Election has concluded, electing Jacob Kaplan-Moss, Sarah Abderemane, and Thibaud Colas to two-year terms. Congratulations to the new members and a heartfelt thank you both to departing board members and all nominees. djangoproject.com Updates to Django Last week we had 22 pull requests merged into Django by 12 different contributors - including 3 first time contributors! Congratulations to Prashant Pandey, Standa Opichal, and trontelj for having their first commits merged into Django - welcome on board! Some key updates from last week: From 5.1, RequestFactory/AsyncRequestFactory/Client/AsyncClient/Client now supports a query_params parameter, which accepts a dictionary of query string keys and values. This allows setting query strings on any HTTP methods more easily. Django has started to test against Python 3.13 alpha. Python 3.13 is scheduled to release October 2024, if all goes well we can expect Django to support Python 3.13 from 5.1. 5 release blockers were resolved last week, and a few more this week! Thank you so much to everyone who has been testing 5.0 💚 Django Newsletter Wagtail CMS StreamField Quick Demo Not sure what StreamField is and why it's amazing? We have a demo …