Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Migrating from Hyde to Hugo
Almost twelve years after the last big site infrastructure change, it’s time for another round. This time is purely technical, with no intentional visual changes. Motivation I haven’t posted in a long time, and this blog had largely faded into the background for me. I was doing some management of my domains, trying to clean things up after my domains registered with Google were transferred to Squarespace. As part of this, I decided to use Cloudfare as my nameserver, which I’ve used for other projects. I started reading about Cloudfare Pages, which seemed like a great match for easily deploying a statically-generated site. You can point Cloudflare to a GitHub repo, and it will automatically kick off a build after every commit, and deploy the static artifacts. Unfortunately, the Hyde framework I was using is no longer maintained, and still does not support Python 3. Cloudflare Pages does not have support for Python 2.7. So I decided it would be a fun project to migrate to a new static site generator. Finding a new tool Searching around, I quickly settled on Hugo due to its large community, and reputation for blazing fast speed. I wasn’t quite sure how the easy … -
Creating Open Graph Images in Django for Improved Social Media Sharing
Although social media algorithms usually discourage posting links so that users stay as long as possible on the network, people often still post links below an introductory post as a comment or reply. Normal links to websites on social media look pretty dull unless you add open-graph images representing that link. In this article, I will show you how you can generate open-graph images for a Django website using web rendering from HTML and CSS. I rely on this technique to generate Open Graph previews for links from DjangoTricks, 1st things 1st, and PyBazaar. What is an Open Graph? Facebook created the Open Graph protocol to allow websites to provide rich representation of any web page. Although it has specifics for websites, articles, profiles, music, and video, the common use case is to have a preview image with a title for social feeds. Open Graph previews work with most well-known social networks, including Facebook, Threads, LinkedIn, Mastodon, and Blue Sky. Open Graph tags are HTML meta tags that you put in the HEAD section, e.g.: <meta property="og:type" content="website" /> <meta property="og:url" content="{{ WEBSITE_URL }}{{ request.path }}" /> <meta property="og:title" content="{{ profile.user.get_full_name }}" /> {% if profile.open_graph_image %} <meta property="og:image" content="{{ … -
Django News - CFPs for DjangoCon Europe and DjangoCongress JP - Jan 10th 2025
News Feedback needed on Content-Security-Policy header support Rob Hudson is seeking feedback on Content-Security-Policy header support and asking for input before Django 5.2's feature freeze by January 15. mastodon.social Django Software Foundation DSF member of the month - Hiroki Kiyohara Hiroki is the creator and a staff member of DjangoCongress JP. He has done a lot for the Django Japan community and has been a DSF member since October 2024. djangoproject.com DSF Board monthly meeting, January 9, 2025 DSF Board monthly meeting minutes for January 9, 2025. djangoproject.com Updates to Django Updates to Django Last week we had 17 pull requests merged into Django by 11 different contributors - including 3 first-time contributors! Congratulations to Ari Pollak, Chaitanya Rahalkar and Harsha Vardhan V for having their first commits merged into Django - welcome on board! Django Newsletter Sponsored Link 1 Django & Wagtail Hosting for just $9/month New year, new site! Finally put those domain names to use and launch that side-project, blog, or personal site in 2025. Lock in this limited time pricing by Feb 28. codered.cloud Articles Django: Fail in templates with {% url '' %} Crashing Django templates on purpose is easier than you might think—just use … -
Simplified Signup - Building SaaS #211
In this episode, we began an update to the signup process to simplify things. I am replacing email and password with just email. Users will receive ‘magic links’ via their email client to sign in. To do this, we are using django-sesame. -
Django: render JavaScript import maps in templates
JavaScript’s import statement lets module scripts import objects from other scripts. For example, you can define a script as a module in HTML: <script type=module src="/static/js/index.js"></script> Then that file can import from another, like: import { BigBlueButton } from "/static/js/lib/buttons.js"; // ... This syntax will work within the context of a Django project, but it’s not ideal. You typically want to render static file URLs with {% static %} rather than hardcode them like /static/js/lib/buttons.js. This way, if you’re using the popular Whitenoise package or Django’s built-in ManifestStaticFilesStorage, the rendered asset URLs will have cache-busting hashed filenames. But you can’t use {% static %} within JavaScript files (without templating them, which prevents you from using other JavaScript tooling on the files, such as Biome). Django 4.2 added experimental import statement rewriting to ManifestStaticFilesStorage. This feature makes collectstatic modify import statements in collected JavaScript files to use hashed filenames. For example, if used on the above file, it might output: import { BigBlueButton } from "/static/js/lib/buttons.decac99afbe8.js"; // ... To activate it, subclass ManifestStaticFilesStorage and set the support_js_module_import_aggregation attribute to True (documentation). But this is marked experimental due to Ticket #34322, which I reported, showing that the changes could break code using … -
Django in 2025
LearnDjango Three Course BundleThe Stack ReportLeuchtturm Weekly PlannerRereading Working in Public Fosstodon Thread DjangoCon Europe CFP Open Until January 12thAn Obvious Statement About Open Source | Christopher Neugebauer | Monktoberfest 2024Django 6.x Steering Council Results DjangoCon Japan, Europe, Africa, and USReimagining OSS Licensing and Commercialization with Fair Source - Adam Jacob, System Initiative -
Django: silence “Exception ignored in ... OutputWrapper”
You might see this message when running pytest on your Django project: $ pytest ... Exception ignored in: <django.core.management.base.OutputWrapper object at 0x108576170> Traceback (most recent call last): File "/.../django/core/management/base.py", line 171, in flush self._out.flush() ValueError: I/O operation on closed file. The message doesn’t fail tests but reports an unraisable exception that occurred inside Django. This is an exception at a point that Python cannot crash the program. It’s triggered by a bug in Django’s OutputWrapper class, which is used to wrap output in management commands when used in combination with pytest’s output capturing. The message can appear twice, once for sys.stdout and once for sys.stderr, for each management command tested for an exception, like: with pytest.raises(CommandError) as excinfo: call_command(...) This message is always visible on Python 3.13+, but it can also appear on older versions when using Python’s development mode, like: $ python -X dev -m pytest (I recommend using development mode locally and on CI; it activates several useful features!) I reported and fixed the underlying issue in Ticket #36056. The commit is scheduled for release in Django 5.2 and will not be backported to older versions. So, until 5.2 is out, your test output can get cluttered with … -
Comment remplacer une chaine par une autre dans le champ d’un Model Django
Je me suis retrouvé il y a quelques temps avec une problématique, remplacer une chaine par une autre dans un attribut CharField d’un model django. La première possibilité était de faire tout simplement une belle boucle sur la totalité de mes instances de module, faire le remplacement en python et sauvegarder la nouvelle valeur. Sauf que j’avais quasiment un million d’objet et que je n’avais pas envie que cela prenne des plombes. Et puis c’était un peu moche. Du coup j’ai un peu fouillé et miracle, j’ai trouvé une solution que voici. On commence par définir la fonction de remplacement, tout en django et en SQL. from django.db.models import F, Func, Value def replace_func(field_name, old_str, replace_str): return Func( F(field_name), Value(old_str), Value(replace_str), function='replace' ) Ensuite, il n’y a quasiment plus rien à faire. On va simplement appeler update sur tout les objets et utiliser replace_func. Par exemple : MonModele.objects.filter(CONDITIONS).update( champ_a_modifier=replace_func("champ_a_modifier", "str_que_lon_veut_remplacer", … -
Django News - 🎊 DjangoCon US 2025, Wagtail Updates, and Tips for Django Developers - Jan 3rd 2025
News DjangoCon US 2025 has been announced! DjangoCon US 2025 is heading to Chicago this September 8 - 12th—mark your calendar, prepare your talk submissions, and join the excitement! defna.org Wagtail CMS Wagtail 6.3.2 Wagtail 6.3.2 includes three bug fixes and a docs update. github.com Articles Database optimization isn't always obvious Database query optimization often defies intuition—Ken Whitesell unpacks why benchmarks, query plans, and context matter more than surface assumptions. github.io Python: create temporary files and directories in unittest Create and manage temporary files and directories in Python tests, with practical tips for unittest and more. adamj.eu Django in 2024 Django proved its versatility in 2024, powering everything from high-traffic APIs to async workflows, while keeping complexity low and teams productive—reminding us why it's still a top choice for modern web development. screamingatmyscreen.com Show Django flash messages as toasts with Htmx Learn how to display Django messages as user friendly toasts with Htmx joshkaramuth.com Getting Started Contributing to Django A collection of resources to help you get started contributing to Django. better-simple.com Introducing Django Template LSP: Smarter Completions for Django Templates - Four Digits Django Template LSP revolutionizes template editing with intelligent autocompletion, navigation, and hover docs, making Django development … -
My 2024 in review
A quick review of my 2024 done in a hurry, trying to remember the many experiences I had, the people I met, the places I visited and the changes I went through. -
Deploying a Django App to AWS ECS with AWS Copilot
This tutorial looks at how to deploy a Django app to AWS ECS with AWS Copilot. -
Django in 2024
2024 was a busy year for me. My clients really kept me on my toes with lots of fun and exciting R&D projects. Nearly all of them were built on the same stack. Some are internally facing, processing about 1.5 million messages asynchronously per day, some are customer facing, with a few hundred requests per second peak, but overall still nothing too crazy. I am sure they will get a bit more traction in 2025. Additional to that we worked on a non profit side project that will likely go online in January. I obviously did not write all these projects from start to finish by myself. For the first four to eight weeks I worked mostly alone on these projects. But during this time there were still other engineers to brainstorm, figure out the API for integration points, get some help with customer specific domain questions and have a project or product manager track down external information that were needed. I was just the lucky one to write code all day and I got to push these things to production for the first time. Which is also the point when we usually brought in more people to add features, … -
Django News - New Django Accessibility Team Members, Performance Pitfalls, and PyCon US 2025! - Dec 27th 2024
News Welcome to our new Django accessibility team members The Django Accessibility Team welcomes new members Eli, Marijke, Tushar, and Saptak, who bring valuable expertise to the project. djangoproject.com Articles Django: avoid using .first() when retrieving a unique object Avoid using .first() to retrieve unique objects in Django to avoid unnecessary performance costs from added ordering; instead, use .get() with proper exception handling for efficiency. github.io This Django Template Tag is Killing Your Performance Avoid performance pitfalls by replacing the length template filter with count() for QuerySet objects to prevent excessive memory and database usage. mirat.dev Better Error Tracking in Django Learn how to enhance error tracking in Django with Bugsink. Explore built-in features, limitations, and robust solutions for debugging and managing errors effectively. bugsink.com Loopwerk: Why I still choose Django over Flask or FastAPI Django's comprehensive features, powerful ORM, seamless migrations, and supportive community make it the go-to choice for building versatile and scalable applications. loopwerk.io Events PyCon US 2025 Registration is open! PyCon US 2025 registration is open, offering flexible rates, early bird discounts, and a packed schedule of events, including tutorials, keynotes, and sprints. pycon.org Podcasts Django Brew: Episode 4: Spoiler Alert: DjangoCon US Recap, Open Source … -
Optimizing SQLite - Building SaaS #210
In this episode, when worked on the newly migrated JourneyInbox site and focused on the database. Since me moved from Postgres to SQLite, I needed to make sure that SQLite was ready for users. We examined common configuration to optimize the database and applied that config to JourneyInbox. -
Django: Fail in templates with {% url '' %}
Previously, I covered using 1/0 to crash Python within minimal typing, useful to quickly answer questions like “does the code even get here?”. Recently, I wanted to do the same in Django templates, to trace if a given template was even being rendered, and under which code paths. It’s a bit more challenging to deliberately crash Django’s template language, since the whole system is designed to be robust, silencing of many kinds of errors. The language is also restricted, so {{ 1/0 }} doesn’t work, as variables cannot contain expressions. Still, after playing around for a bit, I came up with following two options. First, there’s a way to run 1/0, using divisibleby: {{ 1|divisibleby:0 }} On rendering, this raises a classic ZeroDivisionError: ZeroDivisionError: integer modulo by zero That said, divisibleby is a bit long and tricky to type. Second, my preferred method uses the url tag: {% url '' %} The {% url %} looks up URLs by name, so providing it the empty string forces no URL to match, raising a NoReverseMatch error: NoReverseMatch: Reverse for '' not found. '' is not a valid view function or pattern name. I don’t think there is a shorter way to crash using … -
Why I still choose Django over Flask or FastAPI
I started using Django in 2009, and fifteen years later I am still a happy user. Why do I prefer it over Flask or FastAPI? -
Weeknotes (2024 week 51)
Weeknotes (2024 week 51) Building forms using Django I last wrote about this topic in April. It has resurfaced on Mastodon this week. I’m thinking about writing a feincms3-forms demo app, but I already have too much on my plate. I think composing a forms builder on top of django-content-editor is the way to go, instead of replacing the admin interface altogether – sure, you can always do that, but it’s so much less composable… Releases blacknoise 1.2: No real changes, added support for Python 3.13 basically without changing anything. It’s always nice when this happens. django-imagefield 0.21 django-prose-editor 0.10: I rebuilt django-prose-editor from the ground up and wrote about that two weeks ago. The 0.10 release marks the final point of this particular rewrite. django-js-asset 3.0: See the blog post from this week -
Django News - Django 6.x Steering Council Election Results - Dec 20th 2024
News Django 6.x Steering Council Election Results Congrats to our new Steering Council members. Carlton Gibson Emma Delescolle Frank Wiles Lily Foote Tim Schilling djangoproject.com Django Reached 100%+ Funding! Django successfully reached its funding goal of $200,000 for 2024. It speaks to the volunteer-nature of the project that something with so many moving parts and active contributions can thrive on such a relatively limited budget. djangoproject.com Python Insider: Python 3.14.0 alpha 3 is out This is an early developer preview of Python 3.14 featuring several major new features compared to Python 3.13. blogspot.com Django Software Foundation Today 'Updates to Django' is presented by Velda Kiara from Djangonaut Space! Last week we had 14 pull requests merged into Django by 11 different contributors - including 3 first-time contributors! Congratulations to Juan Pablo Mallarino, Ben Cardy, and amansharma612 for having their first commits merged into Django - welcome on board!🎉 Here are some highlights from the recent updates coming to Django 5.2: The migrate and runserver commands now respect the requires_system_checks override, running only the checks tagged with the specified tags. A new hook, get_check_kwargs(), allows for further customization. django.urls.reverse has been enhanced to support query strings and URL fragments, offering more … -
Bootstrap Kamal On Droplet - Building SaaS #209.1
In this episode, I worked to finish the cloud migration to DigitalOcean for JourneyInbox. We started the stream by bootstrapping Kamal on the server. I hit network issues so this stream is split into multiple parts and is of lower quality than normal. -
Docker Image For Kamal - Building SaaS #209.2
In this episode, the second portion of the stream worked on fixing up the Docker image so that we could get the DigitalOcean droplet functional. This is the second stream chunk because I was having network issues and the first stream cut out. -
Postgres To SQLite - Building SaaS #209.3
In this episode, the third portion of the stream covers how I migrated my Heroku-backed Postgres database to SQLite. I finished the migration of my app from running on Heroku to running on DigitalOcean. -
Object-based assets for Django's forms.Media
Object-based assets for Django’s forms.Media The pull request for adding object-based script media assets into Django is in a good state and I hope it will be merged soon. I have been using object-based assets long before Django actually added support for them in 4.1 (since 2016, that’s before Django 1.10!) by using a gross hack. Luckily I have been able to clean up the code when Django 4.1 landed. I have been asking myself at times why I haven’t proposed the change to Django myself despite having been a user of something like this for such a long time. After all, I have been happily contributing issue reports, bug fixes and tests to Django. The process of adding new features sometimes is terribly frustrating though even when looking (and cheering) from the sidelines. It feels bad that adding another package to the list of packages I maintain so clearly seems to be the better way to get things done compared to proposing a new feature for Django itself. I hope processes change somewhat. But I digress. The ProseEditorWidget in django-prose-editor wants to ship CSS, JavaScript and some JSON to the browser for the widget. So, of course I used … -
Django Quiz 2024
Yesterday, I held another quiz at the December edition of Django London. The quiz is a regular tradition at our meetup, a way of having a more relaxed event in December and giving away some nice prizes. This was the sixth quiz that I’ve presented, and the seventh overall. Here’s an action shot taken by my co-organizer Çağıl: And below is the quiz itself, so you can try it at home. Answers follow at the end, with some extra explanation. Dates refer to December 2023, so if you’re reading in the future, take that into consideration. Enjoy! The quiz 1. What is the default port that runserver uses? 8080 8000 8888 404 2. In which month of this year was Django 5.1 released? May August October Undecember 3. What company initially developed Django? Instagram Mozilla Lawrence Journal-World ACME Web Frameworks Inc. 4. What is the CSS selector that ORs a list of selectors? :is() :or() :any() :is-one-of-these() 5. What is the name of the new middleware that requires authentication by default? LoginRequiredMiddleware AuthenticationMiddleware PrivateEverywhereMiddleware FinallyNoMoreAccidentallyPublicViewsMiddleware 6. What is the name of the Django contributor accelerator program? Djangonaut Space Pony Express Astronaut Django All Djangoes Go 7. Which model field would … -
Reflections on DjangoCon US 2024: Highlights, Takeaways, and Community Connections
DjangoCon 2024 was a resounding success for the community, with attendees from all over the world gathering to learn about the latest developments in Django and to connect with the Django community. Caktus was well-represented at the conference, with six of our team members attending. In this blog post, we share our experiences at DjangoCon 2024, including our favorite talks, the people we met, and the things we learned. We also offer some tips for future attendees on how to get the most out of DjangoCon. What did you like most about DjangoCon 2024? Keanya: What I loved most about DjangoCon 2024 was the people. DjangoCon is a celebration of community. I especially appreciated how welcoming the environment was. Whether you’re a seasoned contributor or someone attending their first conference, you’re made to feel like your voice matters. But the best part was the sense of connection. We are all here not just to write code, but to build something meaningful together. Karen: Seeing and getting to catch up some with Django community folk that I only get to see maybe once or twice a year at DjangoCon events. Tobias: For me, DjangoCon 2024 was my first US-based conference since … -
HTTPS for Django Development Environment
Certain modern website features require HTTPS, including Progressive Web Apps (PWA), WebSockets, camera and microphone usage, and geolocation detection. However, the default Django runserver command can only run the web server under HTTP. Is it possible to have HTTPS in your local development environment? Surely, and in this article, I will guide you through how to set it up. How TLS/SSL certificates work First of all, let's have a common ground on how the HTTPS work. HTTPS is what makes websites secure, protecting transferred visitors' data (like passwords or credit card info). TLS (Transport Layer Security), which replaced SSL (Secure Sockets Layer), is the security tool that works behind the scenes to create the safe connection between a client (like a browser) and a server by encrypting the data exchanged. They work using a public key (shared via the certificate) and a private key (kept secret by the server) to establish encrypted connections. These keys are often stored in BASE64-encoded files with extensions like .pem. A Certificate Authority (CA) is a trusted organization or entity responsible for issuing and managing digital certificates used in TLS/SSL encryption. Trusted Certificate Authorities verify the identity of website owners and sign their certificates to …