Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django: build a Microsoft Teams bot
Recently, I built a Microsoft Teams bot for a client, inside their Django project. It wasn’t fun or easy, but the experience did increase my resiliency as a developer. I also went into this forewarned by my wife, a product manager also known as “the integration queen”, who has experienced the difficulties of the Teams API first-hand. I’m writing this post to leave some breadcrumbs for future adventurers braving this path. Issues that I encountered At the core, a Teams bot is a straightforward affair. Microsoft Teams sends HTTP requests to your webhook, to which your code should respond appropriately. Your bot can also send extra requests outside this cycle, to send messages or perform other actions. Unfortunately, there are a lot of complications to getting this process working. Here are some of the issues that I encountered: The documentation is a rat’s nest of competing terms, deprecations, and broken links. This seems to have been driven by rebranding the bot “product” and sub-products as AI and pitching for LLM-driven chatbots. For example, the Python package is referred to all of: “Bot Framework”, “Bot Framework SDK”, and “Bot Builder SDK”. And the Azure service for configuring a bot is called … -
Django Redirects App Tutorial
URL redirects are a fundamental part of maintaining a production website. There are many reasons _why_ you might want to redirect a user from one part of your website to … -
Why I Still Use Python Virtual Environments in Docker
Whenever I publish something about my Python Docker workflows, I invariably get challenged about whether it makes sense to use virtual environments in Docker containers. As always, it’s a trade-off, and I err on the side of standards and predictability. -
Django: avoid “useless use of .all()”
Here’s a little ORM pet peeve of mine that may deepen your understanding of how QuerySets work. Take this code: Digger.objects.all().filter(height_cm__gt=200) The .all() is unnecessary. It’s equivalent to write: Digger.objects.filter(height_cm__gt=200) Why? The manager, Digger.objects, already refers to all Digger objects. Calling .filter() creates a queryset from that manager, with some filtering. Add .all() only adds a useless copy of the queryset between these steps. You only need .all() in a few cases: To create a queryset that intentionally refers to all objects, perhaps for later filtering or slicing: diggers = Digger.objects.all() paginator = Paginator(diggers, 50) ... To delete all objects: Digger.objects.all().delete() Django requires the .all() as confirmation to prevent accidental deletion of a whole table. Useless calls to .all() aren’t a large problem, but they do mean more code to read and a slight performance cost for the extra queryset copies. I think that avoiding them also shows you understand ORM methods a little bit better. Fin May your querysets be lean and legible, —Adam -
Django News - DjangoCon Europe 2026 Call for Organizers - Aug 30th 2024
News Could you host DjangoCon Europe 2026? Call for organizers Posted by Thibaud Colas & DjangoCon Europe Support working group on August 28, 2024 djangoproject.com 10 years of attempting to make open source sustainable Reflecting on 10 years of trying to make open source sustainable readthedocs.com Python Developers Survey 2023 Results Official Python Developers Survey 2023 Results by Python Software Foundation and JetBrains: more than 25k responses from almost 200 countries. jetbrains.com What's new in pip 24.2 — or why legacy editable installs are deprecated A thorough write-up of what's new in pip 24.2 by a new core team member. github.io Updates to Django Today 'Updates to Django' is presented by Raffaella Suardini from Djangonaut Space! Last week we had 11 pull requests merged into Django by 9 different contributors - including 3 first-time contributors! Congratulations to Giovanni Fabbretti, Maarten Breddels and Clifford Gama for having their first commits merged into Django - welcome on board! News in Django 5.2: the function django.utils.html.format_html_join now supports taking an iterable of mappings, passing their contents as keyword arguments to django.utils.html.format_html. Django Newsletter Wagtail CMS Solving the messy middle: a simple block pattern for Wagtail CMS Examine a simple pattern for building block-based … -
Kamal - Building SaaS #200
In this episode, we pulled out a new tool. We spent the session using Kamal, a tool to deploy web apps directly to servers. Kamal offers a complete tool set to get apps running on bare metal or cloud machines. We played with the tool to see how far we go to get an app deployed to a new server. -
Kamal - Building SaaS #200
In this episode, we pulled out a new tool. We spent the session using Kamal, a tool to deploy web apps directly to servers. Kamal offers a complete tool set to get apps running on bare metal or cloud machines. We played with the tool to see how far we go to get an app deployed to a new server. -
Django: rotate your secret key, fast or slow
Django’s SECRET_KEY setting is used for cryptographic signing in various places, such as for session storage and password reset tokens. This makes keeping it secure a high priority since an attacker with the key could forge things like password reset tokens. If you have leaked your secret key, you should rotate it. Committing it to your source code repository should count as a leak because it puts it in the hands of anyone who gains repository access in the future. Two options for rotating Django’s secret key are fast and forceful or slow and soft. Let’s look at them now after a quick tip. Generate a new secret key To make yourself a new secret key, you can use this undocumented-but-stable function from Django: In [1]: from django.core.management.utils import get_random_secret_key In [2]: get_random_secret_key() Out[2]: 'e4t-tdx$+(+d%-jy@d47&+gmohi8)3uwvjcc(fp4%n(jt4ur6v' This function is what Django uses to generate a secret key when you run startproject. Fast and forceful: change SECRET_KEY Use this path if you don’t mind these side effects: logging out all users losing all session data dropping all in-flight messages from the messages framework invalidating all in-progress password reset flows breaking any other uses of Django’s cryptographic signing, such as in django-sesame These … -
No Frills, Just Go: Standard Library Only Web Apps
How much can you build in Go with zero extra packages? What is possible using nothing more than Go’s standard library? In this talk, you’re going to find out! -
No Frills, Just Go: Standard Library Only Web Apps
How much can you build in Go with zero extra packages? What is possible using nothing more than Go’s standard library? In this talk, you’re going to find out! -
Weeknotes (2024 week 35)
Weeknotes (2024 week 35) Getting deep into htmx and django-template-partials I have been skeptical about htmx for some time because basically everything the library does is straightforward to do myself with a few lines of JavaScript. I am a convert now because, really, adding a few HTML attributes is nicer than copy pasting a few lines of JavaScript. Feels good. The combination of htmx with django-template-partials is great as well. I didn’t know I had been missing template partials until I started using them. Includes are still useful, but replacing some of them with partials makes working on the project much more enjoyable. I haven’t yet had a use for django-htmx but I may yet surprise myself. Releases django-authlib 0.17: django-authlib bundles authlib.little_auth which offers an user model which uses the email address as the username. I have also introduced the concept of roles instead of permissions; now I have reorganized the user admin fieldset to hide user permissions altogether. Group permissions are still available as are roles. I’m personally convinced that user permissions were a mistake. feincms3-forms 0.5: Allowed setting a maximum length for the bundled URL and email fields through the Django administration interface. django-content-editor 7.0.7: Fixed a … -
Production-ready Python Docker Containers with uv
Starting with 0.3.0, Astral’s uv brought many great features, including support for cross-platform lock files uv.lock. Together with subsequent fixes, it has become Python’s finest workflow tool for my (non-scientific) use cases. Here’s how I build production-ready containers, as fast as possible. -
There can't be only one
There’s a concept that I’ve heard called by a lot of different names, but my favorite name for it is “the Highlander problem”, which refers to the catchphrase of the campy-yet-still-quite-fun Highlander movie/TV franchise. In Highlander, immortal beings secretly live amongst us and sword-fight each other in hopes of being the last one standing, who will then get to rule the world forever. And when one of them is about to eliminate another, … Read full entry -
KISS Beats Accidental Complexity
Our friends at Sanvira published a blog post about a Django project they shipped five years ago, which is still running today without change, hand holding or application server restart. I really enjoy stories like this. Small, well engineered monoliths, just sitting there doing their job and not randomly breaking. While this sounds trivial it is not – and it is by far not the standard. I have seen enough systems fall apart for random reasons. Missing database indexes being on top of the list. The other thing that stands out to me are the frameworks and libraries. You can start nearly any web project with the exact same components today. (Ignoring VueJS - I reserve the right to not have an opinion on technologies and in domains I am not involved in.) APIs might have changed a bit. Functionality was added and bugs have been fixed. But they are all still around, doing well and have proven to be production ready. Compare that to ecosystems which reinvent package management every other week. -
Django Tailwind
This tutorial demonstrates how to configure Django and TailwindCSS from scratch in a new project. ## Django Setup Create a new virtual environment called `.venv`. ``` # Windows … -
Django News - Wagtail 6.2.1 release - Aug 23rd 2024
News PyPI Slashes Malware Response Time: 90% of Issues Resolved in Under 24 Hours PyPI has drastically improved its malware response times, resolving 90% of issues in under 24 hours and removing 900 projects since March 2024. socket.dev Updates to Django Today 'Updates to Django' is presented by Lilian from Djangonaut Space! Last week we had 12 pull requests merged into Django by 9 different contributors - including 2 first-time contributors! Congratulations to Marc Picaud and Mohammad Salehi for having their first commits merged into Django - welcome on board! News in Django 5.2: Added support for validation of model constraints which use a GeneratedField. The new Expression.set_returning attribute specifies that the expression contains a set-returning function, enforcing subquery evaluation. This is necessary for many Postgres set-returning functions. Django Newsletter Wagtail CMS Wagtail 6.2.1 release notes Four new bugfixes in the latest release. wagtail.org Sponsored Link 1 Free Trial of Scout APM Today! Need answers to your Django app questions fast? Avoid the hassle of talking with a sales rep and the long wait times of large support teams, and choose Scout APM. Get Django insights in less than 4 minutes with Scout APM. scoutapm.com Articles Django UserProfile Model How … -
Golang Middleware and DBs - Building SaaS #199
In this episode, we continued the break from JourneyInbox to look through more of the Go standard library. In this session, we talked about middleware, request context, and using databases. -
Golang Middleware and DBs - Building SaaS #199
In this episode, we continued the break from JourneyInbox to look through more of the Go standard library. In this session, we talked about middleware, request context, and using databases. -
Django UserProfile Model
Every website needs a way to handle user authentication and logic about users. Django comes with a built-in [User model](https://docs.djangoproject.com/en/5.1/ref/contrib/auth/#user-model) as well as views and URLs for login, log out, … -
Custom Error Messages on Model Deletion in the Django Admin
I have been working on a project where we might want to delete models even just for testing purposes, but we don't want to accidentally delete models. Protect Model Deletion Let's say you have a Django model: from django.db import models class User(models.Model): name = models.CharField(max_length=255) email = models.EmailField() class Rental(models.Model): name = models.CharField(max_length=255) current_renter = models.ForeignKey( User, on_delete=models.CASCADE, null=True, blank=True ) At some point, I might sell and delete my Rental object, but I don't want to do that if I have someone renting it at the moment. Override Model delete() Method We can put in our own custom logic to prevent this deletion if there's an active renter: from django.core.exceptions import ValidationError # new class Rental(models.Model): # ... def delete(self, *args, **kwargs): # Check if someone is renting at the moment if self.user_set.exists(): raise ValidationError( f"Cannot delete rental {self.name} while someone is in it." ) # If no renter, proceed with deletion super().delete(*args, **kwargs) Message the User by Overriding the delete_model() Method In our Model's Admin class, we can override the delete_model() method to give the user feedback as to why we stopped their deletion so they aren't left totally confused: from django.contrib import admin from django.contrib import … -
How I handle versioning
How I handle versioning I have been reading up on versioning methods a bit, and I noticed that I never shared my a bit unorthodox versioning method. I previously wrote about my rules for releasing open source software but skipped everything related to versioning. I use something close to the ideas of semantic versioning but it’s not quite that. Note that the versioning scheme has nothing to do with production readiness, it’s more about communicating the state of the project. 0.0.x – Everything breaks I don’t trust my choices a lot. Everything may radically change, and I may also abandon the project with no hard feelings. 0.1.0 – Changelogging I generally start writing release notes or rather a Changelog, since writing full release notes is much more work. You absolutely have to test the software and I do not guarantee anything related to backwards compatibility – just that you’ll know about breaking changes when you read the CHANGELOG. ?.?.x – Bugfixes and pure additions Strictly speaking, patch version increments are only for bugfixes. However, when I add new features which are purely additional to the package or if there’s no way (famous last words) that anything will break, I’ll upload … -
Limiting Content Types in a Django Model
This article looks at how to limit the content types in a Django model. -
Django News - Django 5.2 News - Aug 16th 2024
News PSF Community Service Awards to Kojo Idrissa! 🎉 Congratulations to Kojo Idrissa on his well-deserved Community Service Award. This award was given to Kojo for delivering insightful talks, organizing events like DjangoCon US, and engaging in discussions with developers and new Python developers. Kojo consistently champions the growth and inclusivity of the Python ecosystem. python.org Announcing PSF Fellow Members for Q1 2024! 🎉 Congratulations to Adam Johnson and Paolo Melchiorre on becoming PSF Fellows for 2024. blogspot.com DjangoCon US Keynotes: Natalia Bidart Django Fellow, Natalia Bidart, is keynoting DjangoCon US 2024 this fall. In-person and online tickets are available. djangocon.us VSCode Pre-Release of Running Tests Django tests are now supported in the VS Code Python extension! This is currently a pre-release, so we appreciate any users who can try it out and provide feedback or submit bugs. github.com Django Software Foundation DSF Board monthly meeting, August 8, 2024 Meeting minutes for DSF Board monthly meeting, August 8, 2024 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 12 different contributors - including 2 first-time contributors! Congratulations to Jure Cuhalev and Farhan … -
More Go Standard Library - Building SaaS #198
In this episode, we continued the break from JourneyInbox to look through more of the Go standard library. In this session, we explored JSON serialization, Go template support, and embedding of static files for easy access. -
More Go Standard Library - Building SaaS #198
In this episode, we continued the break from JourneyInbox to look through more of the Go standard library. In this session, we explored JSON serialization, Go template support, and embedding of static files for easy access.