Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django admin tip: Adding links to related objects in change forms
Django admin tip: Adding links to related objects in change forms Any issue which came up on the Django Forum and Discord is how to add links to other objects to the Django administration interface. It’s something I’m doing often and I want to share the pattern I’m using. It’s definitely not rocket science and there are probably better ways to do it, but this one works well for me. Method 1: Override the change form template In one project users can be the editor of exactly one organization. The link between organizations and users is achieved using a Editor model with a ForeignKey(Organization) and a OneToOneField(User). I wanted to add a link to the organization page at the bottom of the user form. An easy way to achieve this is to add a template at templates/admin/auth/user/change_form.html (or something similar if you’re using a custom user model): {% extends "admin/change_form.html" %} {% block after_related_objects %} {{ block.super }} {% if original.editor %} <fieldset class="module aligned"> <h2>Organization</h2> <div class="form-row"> <a href="{% url 'admin:organizations_organization_change' original.editor.organization.pk %}">{{ original.editor.organization }}</a> </div> </fieldset> {% endif %} {% endblock after_related_objects %} The original context variable contains the object being edited. The editor attribute is the reverse … -
Django News - Django 5.1.5 security release - Jan 17th 2025
News Django security releases issued: 5.1.5, 5.0.11, and 4.2.18 Several new security updates. As ever, you should endeavor to be on the latest version of Django for security reasons. djangoproject.com Django 5.2 alpha 1 released Django 5.2 alpha 1 is now available. It represents the first stage in the 5.2 release cycle and is an opportunity for you to try out the changes coming in Django 5.2. djangoproject.com Python Insider: Python 3.14.0 alpha 4 is out Python 3.14 is still in development. This release, 3.14.0a4, is the fourth of seven planned alpha releases. python.org Djangonaut Space Session 4 Applications Open! Djangonaut Space Applications are open now and close on January 29th, 2025 AOE. djangonaut.space Django Software Foundation Hello from the new Steering Council; and a quick temporary voting process change An update on the voting process to move faster on the smaller things the SC currently has in from of them. djangoproject.com Updates to Django Today 'Updates to Django' is presented by Velda Kiara from Djangonaut Space! Last week we had 20 pull requests merged into Django by 12 different contributors 🎊! Highlights of the changes made: The contrib.postgres aggregates ordering argument has been deprecated in favor of order_by. URLField … -
Thinking About Risk: Sidebar #3: Two Flavors of Medium Risk
When you look at a likelihood/impact risk matrix, you might notice that “medium” appears twice – once as high-likelihood/low-impact, and once as low-likelihood/high-impact. These two “mediums” aren’t at all the same! -
Building SaaS with Python and Django #212.2
In this episode, we continued on the sign up workflow simplification. The focus of this stream was on adding the background task that will send the magic link email to allow sign in. This is the second half of the stream because my internet cut out. -
Signin Email - Building SaaS #212.1
In this episode, we continued on the sign up workflow simplification. The focus of this stream was on adding the background task that will send the magic link email to allow sign in. -
Built with Django Newsletter - 2025 Week 3
Hey, Happy Thursday! Why are you getting this: *You signed up to receive this newsletter on Built with Django. I promised to send you the latest projects and jobs on the site as well as any other interesting Django content I encountered during the month. If you don't want to receive this newsletter, feel free to unsubscribe anytime. News and Updates Happy New Year! Hope the first 16 days of 2025 have been good to you! Hope this year will be the best one for you so far! I haven't been to proactive with Built with Django updates unfortunately. So much has been going on with personal life and work that it left very small amount of time for side projects. Starting to pick up the pace fortunately, will see what will be coming. If you have any requests/ideas for the website, please let me know! What I'm hoping to do in the coming months is up the number of posts on the blog, and hopefully start doing some video tutorials. Sponsors This issue is sponsored by SEO Blog Bot. Well, sponsor is a strong word. It is just another project of mine that I wanted to share with you … -
Thinking About Risk: Sidebar #2: The Swiss Cheese Model
In the real world, accidents happen when a series of small missteps align to create severe consequences. This is something we call the “Swiss Cheese Model”: imagining a systems failure as a set of “holes” in our layers of defense that all line up to create a series accident. -
New upcoming Dutch python meetup: Leiden (NL)
Important things first: 27 January there's a python meetup in Leiden (NL) of the new python Leiden user group. Meetup groups come and go, often depending on one or two people or on a company that organises it. And yes, meetup.com has basically cornered the market, at least in my experience. There used to be a "PUN", python usergroup Nederland, meeting that would be held in various cities, depending on the company that hosted it in turn. (For those in NL: Den Haag, Zoetermeer, Rotterdam, Utrecht, Veenendaal, Arnhem, Amsterdam, ...). Managed via a mailinglist, as meetup.com didn't exist yet. Later lots of python and/or django meetup.com-based-meetups were organised. To me, it felt a bit weird that all of them seemed to be city-oriented. Amsterdam python meetup (3 different ones), Amsterdam django meetup, Utrecht (2x), Eindhoven, Rotterdam. I went to many of them, mostly it is just an hour of travel by public transport :-) I like going to those meetups. You get a feel for what people are doing with python. You get ideas. You learn about libaries (sometimes even from the standard library) that you didn't know about. New python tricks. For me, it is a great method to … -
Database Indexing in Django
This article explores the basics of database indexing, its advantages and disadvantages, and how to apply it in a Django application. -
Weeknotes (2025 week 03)
Weeknotes (2025 week 03) Claude AI helped me for the first time django-imagefield prefers processing thumbnails, cropped images etc. directly when saving the model and not later on demand; it’s faster and also you’ll know it immediately when an image couldn’t be processed for some reason instead of only later when people actually try browsing your site. A consequence is that if you change formats you have to remember that you have to reprocess the images. The Django app comes with a management command ./manage.py process_imagefields to help with this. I have added parallel processing based on concurrent.futures to it some time ago so that the command completes faster when it is being run on a system with several cores. A work colleague is using macOS (many are, in fact), and he always got multiprocessing Python crashes. This is a well known issue and I remember reading about it a few years ago. I checked the docs and saw that the concurrent.futures page doesn’t mention macOS, but multiprocessing does. So, I hoped that a simple rewrite of the management command using multiprocessing might fix it. Because I was in a rush and really didn’t want to do it I turned … -
Thinking About Risk: Sidebar #1: "Exposure"
Risk is usually defined as the product of two factors: Likelihood and Impact. However, some disciplines include a third factor: Exposure. What’s that about, and when is it useful? -
Don’t automate screenshots, automate iframes
There’s a lot of tools out there to automate taking screenshots for documentation of web apps/libraries. Screenshots are certainly sometimes a good idea, but they have some serious downsides: As you’re sending pixels instead of text, screen readers don’t work Screenshots adjust badly to zoom levels Responsive layouts don’t work Automatic dark mode selection doesn’t work They are larger to download They are hard to generate They are slow to generate When writing the iommi documentation I realized that I can bypass all that by using embedded iframes instead of screenshots. Instead of spinning up a headless Chrome, writing playwright/selenium automation and suffering through all that, I can render the page I am documenting like normal, and save the html to disk, which is then linked to with an iframe. It required some custom tooling, but check out the iommi cookbook for examples and I think you’ll agree the results are pretty great. Here’s a sample test from the cookbook that generates the iframe, and then the rST file for the docs: def test_how_do_you_turn_off_pagination(small_discography): # language=rst """ How do you turn off pagination? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Specify `page_size=None`: """ table = Table( auto__model=Album, page_size=None, ) # @test show_output(table) # @end The show_output … -
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 …