Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Pycon NL: The attentive programmer - Daniele Procida
(One of my summaries of the one-day Pycon NL conference in Utrecht, NL). Personal note beforehand: I'd like to point at a previous talk by Daniele at djangocon EU in 2014 about diversity in our industry. Daniele once interviewed a programmer for a position. "Why do you enjoy programming?" The answer: "When I'm programming, I'm a god. I create things out of clean air." You can create things. It is more than "doing things". Or "merely commanding". I cannot make something exist in the real world just by saying "let there be light". But in programming I can! I can do x = 1 or c = Camera(). Programming as intention. "Fiat voluntas tua", thy will be done. You want something. In programming, you even write tests to check whether what you intended actually turned out right :-) Daniele likes to program, but isn't really good at it. Which is fine with him. He also likes photography, but isn't really good at it, too: this one hurts him quite a bit more. A famous photographer once said "your first 1000 photos are your worst". But once you stop for a while, the counter seems to reset to zero. Programming as … -
Built with Django Newsletter - 2024 Week 41
Hey, Happy Tuesday! 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 Last week Ramy from Hovercode purchased my first ad space! Thank you Ramy! Still trying to grow a pair and start recording video tutorials for you guys. Decided to keep my skills fresh and relevant and built a new app over the weekend. OSIG is a free and open-source solution to generating beautiful OG images on the fly! I shared the project on Hacker News today, would mean a lot if you could support it :) Thanks a ton in advance. Sponsors This issue is sponsored by OSIG. Well, sponsor is a strong word. It is just another project of mine that I wanted to share with you 🙈. Fully free! If you want an automated way for generating OG images for social media, this might be for you. If you want to become a real sponsor, just reply … -
If we had $1,000,000…
What would the Django Software Foundation look like if we had 4x our current budget? -
Django News - 2025 DSF Board Nominations - Oct 4th 2024
News PyCharm & Django Campaign 2024 - encore Each year, our friends at JetBrains, the creators of PyCharm, run an incredible deal. You get a 30% discounted year of PyCharm, AND the DSF gets 100% of the money. Yes, 100%! djangoproject.com 2025 DSF Board Nominations Nominations are open for the 2025 Django Software Foundation Board of Directors. Of our 7 directors, there are 4 positions currently open, with each position serving for two years. djangoproject.com Django TV A new website dedicated to promoting Django and Python videos from conferences. Read more about the inspiration here. djangotv.com Speaking at PyTexas - PyTexas Conference Our CFP opens October 1, 2024 and closes December 1, 2024. pytexas.org DJP: A plugin system for Django DJP is a new plugin mechanism for Django, built on top of Pluggy. I announced the first version of DJP during my talk yesterday at DjangoCon US 2024, How to … simonwillison.net Updates to Django Today 'Updates to Django' is presented by Raffaella Suardini from Djangonaut Space! Last week was DjangoCon US but we still had 4 pull requests merged into Django by 4 different contributors. These included a regression fix in Django 5.1 that caused a crash when using … -
Custom Django Python Migration
Sometimes I find myself wanting to add some model objects along with a feature. You can make a custom migration to handle that! Overview of what we will do Create an empty migration Create a forwards operation Create a backwards operation Tie those operations to the migration Apply, un-apply, and re-apply the migration Whole file contents For a tl;dr, make an empty migration and populate it like this: # Generated by Django 5.1.1 on 2024-10-03 12:59 from django.db import migrations def forwards(apps, schema_editor): MyModel = apps.get_model('my_app', 'MyModel') MyModel.objects.create( field_name1="name", field_name2="describe" ) def backwards(apps, schema_editor): MyModel = apps.get_model('my_app', 'MyModel') MyModel.objects.get( field_name1="name", field_name2="describe" ).delete() class Migration(migrations.Migration): dependencies = [ ("app_name", "0001_initial"), # could be more here ] operations = [ migrations.RunPython(forwards, backwards), ] Create an empty migration python manage.py makemigrations --empty I tend to add a descriptive name as well: python manage.py makemigrations \ --name \ --empty The empty file should look something like this: # Generated by Django 5.1.1 on 2024-10-03 12:59 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("app_name", "0001_initial"), # could be more here ] operations = [] Create the change you want to see Next, I'm going to add a top-level function that runs the code … -
DjangoCon US 2024 Recap - Tim Schilling
Better Simple websiteTim on Mastodondjango-commonsDjango commons discussionsAspirEDUDjangonaut Space and on Open CollectiveDEFNADjangoCon US 2025 Call for VolunteersLacey’s interview with Jay Miller at DCUS2024Google Summer of Code - Django Debug ToolbarSponsorDjango + HTMX Course at TalkPython Training 10% off -
Ethical Applications of AI to Public Sector Problems
There have been massive developments in AI in the last decade, and they’re changing what’s possible with software. There’s also been a huge amount of misunderstanding, hype, and outright bullshit. I believe that the advances in AI are real, will continue, and have promising applications in the public sector. But I also believe that there are clear “right” and “wrong” ways to apply AI to public sector problems. -
Say Goodbye to FOMO: How I Built a Telegram Bot to Keep You on Top of Important Conversations
No more FOMAIntroduction:In today’s hyper-connected world, many of us experience FOMO — the Fear of Missing Out. It’s the anxiety that critical information or events are happening, and you’re not aware of them. This is especially true for fast-paced Telegram channels, where immigrants and other communities share essential updates about legal assistance, jobs, and housing.To address this, I built a Telegram bot that helps eliminate FOMO by summarizing past and recent conversations. It highlights key points and urgent matters, giving you a quick overview of what you should care about. The bot not only analyzes current chats but also processes conversation history, allowing you to get insights from past years’ discussions. It leverages OpenAI’s chat completion and file search tools to deliver the information you need in a concise, actionable format.Key Features of the Bot:Summary Generation: The bot creates concise summaries of both current and past conversations.Urgent Alerts: It highlights urgent messages that require immediate attention.Customizable Insights: You can focus the bot on specific themes, keywords, or time periods.Historical Analysis: It processes exported conversation history files from official Telegram clients, giving you insights from past years’ discussions.Multi-Channel Support: The bot monitors multiple channels and provides summaries across conversations.What is FOMO … -
Django News - 2025 DSF Board Nominations - Sep 27th 2024
News 2025 DSF Board Nominations Nominations are open for the 2025 Django Software Foundation Board of Directors and there are 4 positions currently open, with each position serving for two years. djangoproject.com PyCharm & Django Campaign 2024 - encore The Django Software Foundation's biggest fundraising event of the year is here! djangoproject.com Updates to Django Today 'Updates to Django' is presented by Raffaella Suardini from Djangonaut Space! Last week we had 18 pull requests merged into Django by 14 different contributors - including a first-time contributor! Congratulations to r0Zh-ovanya for having their first commits merged into Django - welcome on board! News in Django 5.2: CharField.max_length is no longer required to be set on SQLite, which supports unlimited VARCHAR columns. PR #18582 Data loaded from fixtures and from migrations enabled with serialized_rollback=True are now available during TransactionTestCase.setUpClass(). PR #18514 Each serialization format now defines a Deserializer class, rather than a function, to improve extensibility when defining a custom serialization format. PR #18335 Django Newsletter Sponsored Link 1 Get 30% off PyCharm. 100% Donated to Django. Support the rapid development of Django! Until October 7th, get PyCharm for your Django development with a 30% discount via this link. All proceeds will … -
Postgres to SQLite - Building SaaS #204
In this episode, we worked on the cloud migration’s data strategy. I focused on how to convert a Postgres database into a SQLite database and planned out the process that I will follow to do the actual migration. -
Postgres to SQLite - Building SaaS #204
In this episode, we worked on the cloud migration’s data strategy. I focused on how to convert a Postgres database into a SQLite database and planned out the process that I will follow to do the actual migration. -
Developing with Docker
You'd think that this topic would have been done to death, but given that every job I've started in the past 10+ years has used Docker differently (if at all) to varying degrees of success, I feel like we need some sense of consensus around how to Do This Right™. And, as someone with an ego the size of a small moon, I'm here to decide what's right... on my own blog anyway. The argument here is that the use of Docker and various tooling shouldn't be unique to any particular project, that this sort of thing should be so standard it's both common and boring to even think about. My experience tells me that we're not there yet though, so this is just me making the case for what I think constitutes a good setup. Thesis The main argument I want to make is that if you're using Docker, you don't write software anymore, but rather you build immutable images. Images that are developed locally, tested in CI, and deployed to production, but importantly, the image at each of these stages is exactly the same: reproducible at every turn. There's little value in developing and testing one thing if … -
Django: Introducing Djade, a template formatter
Happy DjangoCon US 2024 to you. Whilst I am not there, I have adopted the spirit of the season and got to work hacking together a new tool. Djade is a formatter for Django templates. It applies rules based on the template style guide in Django’s contribution documentation, plus some more. Ryan Cheley put together this section back in February (forum discussion). I enjoyed contributing to this discussion and wrote “I’d love to work on a formatter tool to match the guide”. Well, now I did it :) Djade has a similar philosophy to Black, the popular Python code formatter: You can have any colour you like, as long as it’s [d]jade. Djade has no options, just one consistent style, open to community discussion. It also aims to format only Django template syntax, leaving the surrounding language syntax (HTML, TXT, XML, ...) untouched for safety. Djade is built in Rust, using a translation of the relevant parts of Django’s template parser. It’s fast: a quick benchmark on my MacBook shows it takes ~20ms to format 377 templates in one project. Run Djade on your template files directly or with its pre-commit integration. You’ll find it makes changes like: -{% extends … -
Weeknotes (2024 week 39)
Weeknotes (2024 week 39) CSS for Django forms Not much going on in OSS land. I have been somewhat active in the official Django forum, discussing ways to add Python-level hooks to allow adding CSS classes around form fields and their labels. The discussion on the forum and on the pull request goes in the direction of allowing using custom BoundField classes per form or even per project (instead of only per field as is already possible today). This would allow overriding css_classes, e.g. to add a simple class="field". Together with :has() this would probably allow me to skip using custom HTML templates in 99% of all cases. I have also been lurking in the Discord, but more to help and less to promote my packages and ideas :-) Releases django-user-messages 1.1: Added Django 5.0, 5.1 to the CI, and fixed the migrations to no longer mention index_together at all. It seems that squashing the migrations wasn’t sufficient, I also had to actually delete the old migrations. blacknoise 1.1: Starlette’s FileResponse has gained support for the HTTP Range header, allowing me to remove my homegrown implementation from the package. The blacknoise implementation is now half as long as it was … -
DjangoCon US 2024 - Short Summary
I apologize in advance for (1) the brevity, and (2) that not every talk is listed here. I didn't get a chance to watch them all yet. I do not mean any disrespect to any speaker who spoke, but is not listed here. Hopefully this can serve as a taste of the conference. I had a great time at DjangoCon US 2024, and I hope to see you next year! Day 1 Learning, Teaching Sheena O'Connell - Power to the People who Teach the People (Sheena's slides) "Make It Stick" by Peter C. Brown, Henry I. Roediger III, and Mark A. McDaniel. Mastery-based Learning Self-efficacy SPA vs Progressive Enhancement Chris May - Choosing Wisely: SPA vs. HTMX for Your Next Web Project "Progressive enhancement" means your site still works without JavaScript. The longer someone is on a page, the more likely a SPA would be useful. - 20+ operations on the same subset of data? - UI for chat or conversations? Katie Sylor-Miller's "Component Islands" explained in "Islands Architecture" by Jason Miller. The browser can handle a lot of things without JavaScript. Streamed HTML components Article series from Alex Russell on JavaScript excess. Packages: django-unicorn, htmx, alpinejs, django-template-partials, django-components, datastar, … -
Django News - 2024 Malcolm Tredinnick Prize nominations - Sep 20th 2024
News Nominate a Djangonaut for the 2024 Malcolm Tredinnick Memorial Prize Nominations are open until Monday, September 30th, 2024. Learn more about past winners here. djangoproject.com Last call for DjangoCon US 2024 tickets! It's the very last call for DjangoCon US 2024 tickets! djangoproject.com Django Software Foundation Could you host DjangoCon Europe 2026? Call for organizers We are looking for the next group of organizers to own and lead the 2026 DjangoCon Europe conference. djangoproject.com Updates to Django Today 'Updates to Django' is presented by Raffaella Suardini from Djangonaut Space! Last week we had 16 pull requests merged into Django by 8 different contributors - including 2 first-time contributors! Congratulations to khanxmetu and Gastón Avila for having their first commits merged into Django - welcome on board! News in Django 5.2: The new Model._is_pk_set() method allows checking if a Model instance’s primary key is defined. PR #18450 HttpRequest.accepted_types is now sorted by the client’s preference, based on the request’s Accept header.PR #18415 The new HttpRequest.get_preferred_type() method can be used to query the preferred media type the client accepts.PR #18415 Django 5.1.2 will also contain a fix for a regression that caused a crush when using the PostgreSQL lookup trigram_similar on … -
Docker Go, JS, Static Files - Building SaaS #203
In this episode, we continued on the cloud migration path. We need to build a Docker container with all the necessary static files. Some of these come from Go via Hugo for a content blog. Some comes from JavaScript via Tailwind for CSS. Some come from Python via Sphinx for documentation. All need to built into the same image. That’s what we covered on this stream. -
Docker Go, JS, Static Files - Building SaaS #203
In this episode, we continued on the cloud migration path. We need to build a Docker container with all the necessary static files. Some of these come from Go via Hugo for a content blog. Some comes from JavaScript via Tailwind for CSS. Some come from Python via Sphinx for documentation. All need to built into the same image. That’s what we covered on this stream. -
Django Fellows - Natalia Bidart & Sarah Boyce
Django Fellowship Program Django 5.1 Release Notes Natalia’s DjangoCon US Keynote Mastodon for Natalia and Sarah Django Core Demystified talk by Sarah Inside Out: DjangoCon US 2023 talk by Natalia Djangonaut Space DjangoCon US 2024 Contributing to DjangoDEP 0014: Background Workers Everything CurlSponsorDjango + HTMX Course at TalkPython Training 10% off -
Django: speed up tests slightly by disabling update_last_login
Django’s test client provides two methods to log in a user: login() and force_login(). The latter one is faster because it bypasses the authentication backend, including password hashing, and just sets a session to have the user logged in. Typically, you’d want to use it in setUp() like this: from http import HTTPStatus from django.test import TestCase class CornCobListViewTests(TestCase): @classmethod def setUpTestData(cls): cls.user = User.objects.create_user( username="testuser", password="12345", ) def setUp(self): self.client.force_login(self.user) def test_success(self): response = self.client.get("/cobs/") assert response.status_code == HTTPStatus.OK ... When profiling some client tests last week, I spotted that force_login() still took several milliseconds. Drilling down revealed that there was one query to create the session and another to update the user’s last_login field. This update comes from the update_last_login() function (source): def update_last_login(sender, user, **kwargs): """ A signal receiver which updates the last_login date for the user logging in. """ user.last_login = timezone.now() user.save(update_fields=["last_login"]) This receiver is conditionally registered in the django.contrib.auth app config (source): class AuthConfig(AppConfig): ... def ready(self): ... # Register the handler only if UserModel.last_login is a field. if isinstance(last_login_field, DeferredAttribute): from .models import update_last_login user_logged_in.connect(update_last_login, dispatch_uid="update_last_login") ... Well, an extra query per force_login() is not a big deal, but with several thousand tests, … -
PyUtrecht: FFIne, building foreign function interfaces - Marten Wijnja
(One of my summaries of the Dutch PyUtrecht meetup in Utrecht, NL). Full title: this is FFIne: building foreign function interfaces without shooting yourself in the foot. He works at channable (the host). They have both haskell and python codebases. Haskell is used for the more performance-critical code. They looked into using haskell from within python. With a foreign function interface. In some cases Haskell is faster. And it is handy to circumvent the "global interpreter lock" GIL. And sometimes there's a library for which there is no good alternative. Just so you know: many of the libraries you commonly use actually use another more system-oriented language under the hood. You need a host language: python, of course. And an embedded language that can compile to a dynamic library such as C, haskell and others. And third you need python's ctypes module. With ctypes you can load external libraries, including some necessary bookkeeping like input/output types. Behind the scenes, ctypes treats everything like C, including the problems iwth memory management, datatype mapping problems and undefined behaviour... The alternative to including such a libary via ctypes would be to running the other library in its own web server code and call … -
PyUtrecht: Repos are like children, parenting 101 - Bart Dorlandt
(One of my summaries of the Dutch PyUtrecht meetup in Utrecht, NL). Parenting and coding: choices have an effect. What is the outcome of your work? How does it turn out? But in the end you want to be proud of the outcome. You want your child/code to turn out right. With code, the effect of your decisions is clear reasonably quickly, with children it takes some more time. One repo turns into two repos and into three. And more. How do you keep them all the attention they deserve? How do you keep them up to date? Describe your child (=readme). Keep a journal (=changelog). Easy maintenance and easy to work with. Kids need boundaries. They need to know how to behave! Likewise, your code needs to behave: you need tests to set boundaries. After a while, your kid is old enough to go to school. Four years old or so. Hurray: you suddenly have more free time! Apparently your code is still alive! Potty training accomplished. Is your child/code ready to be shared with a wider public? But are you ready for others to make changes to your child? Some things are standard (or should be standard) for … -
PyUtrecht: Teaching yourself how to code - Joris Hoendervangers
(One of my summaries of the Dutch PyUtrecht meetup in Utrecht, NL). Joris started out as a bond trader, with his MSc in financial management. So definitively no programmer by education. Bond trading meant shouting on the stock market's floor, something that was in risk of being automated. So he moved on. In his case to Reuters, one of the two big financial information suppliers. Later he started using python and making nice prototypes, which clients loved. Now he's a python trainer ("PythonSherpa"). A bit of imposter syndrome was present when he was demoing some jupyter notebooks to expensive managers when he was still a python beginner. Later on as python trainer, imposter syndrome was still a thingy. The best way to learn: learning by teaching! He had to keep learning things because he needed to explain them. And by explaining he remembered it even better. But one thing kept worrying him: he couldn't pass many of the standard programming interview questions like "validate this binary search algorithm"... The solution could be online courses on coursera, edx, udacity, udemy. What he recommends is https://github.com/ossu/computer-science, an overview of free courses you need to do to theoretically pass a full computer science … -
PyUtrecht: The Earley Lark parses more: from structured text to data classes - Dan Jones
(One of my summaries of the Dutch PyUtrecht meetup in Utrecht, NL). Take your average "advent of code" text parsing problem. First try: some basic string.split() stuff. Not very readable and a bit brittle. Second try: a feast of regex'es.... More elegant, but much less readable. A regex can parse regular text. If text isn't regular, you have to get to "EBNF", extended Backus-Naur form. This is what lark can help you parse. In lark you define a grammar. You can import pre-defined parts of vocabulary like "signed number" or "quoted string". You can define custom types/variables. And you can group stuff. So first some number of "account statements", followed by "whitespace", followed by "transaction statements", for instance. After parsing with lark, you can then process the results. A useful thing you can do is to convert everything to python dataclasses. When you pair it with pydantic, you get even easier type coercion and validation. A nice quote by Miriam Forner: writing code is communicatng to your future self and other developers. So: readability matters. And Lark can help. -
django-content-editor now supports nested sections
django-content-editor now supports nested sections django-content-editor (and it’s ancestor FeinCMS) has been the Django admin extension for editing content consisting of reusable blocks since 2009. In the last years we have more and more often started automatically grouping related items, e.g. for rendering a sequence of images as a gallery. But, sometimes it’s nice to give editors more control. This has been possible by using blocks which open a subsection and blocks which close a subsection for a long time, but it hasn’t been friendly to content managers, especially when using nested sections. The content editor now has first-class support for such nested sections. Here’s a screenshot showing the nesting: Finally it’s possible to visually group blocks into sections, collapse those sections as once and drag and drop whole sections into their place instead of having to select the involved blocks individually. The best part about it is that the content editor still supports all Django admin widgets, as long as those widgets have support for the Django administration interface’s inline form events! Moving DOM nodes around breaks attached JavaScript behaviors, but we do not actually move DOM nodes around after the initialization – instead, we use Flexbox ordering to …