Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django News - Django 5.1 alpha 1 released - May 24th 2024
News Django 5.1 alpha 1 released Django 5.1 alpha 1 is now available. It represents the first stage in the 5.1 release cycle and is an opportunity for you to try out the changes coming in Django 5.1. djangoproject.com Updates to Django Today 'Updates to Django' is presented by Lilian from Djangonaut Space! Last week we had 11 pull requests merged into Django by 8 different contributors - including 1 first-time contributor! Congratulations to Zeyad Moustafa for having their first commits merged into Django - welcome on board! Ever wonder about the tradeoff between security and performance of password hashers? Django's ScryptPasswordHasher originally had the parallelism parameter set to p=1, however OWASP has a recommendation of p=5. PR #18157 includes this change to follow the recommendation and is part of Django 5.1. In other news, Google Summer of Code officially kicks off next week, and there are four Django projects this year! Congratulations to the participants, and have fun working on these interesting projects! AmanPandey - Add Async Support to Django Debug Toolbar Salvo Polizzi - Auto Importing Shell Csirmaz Bendegúz - Django ORM support for composite primary keys Shafiya Adzhani - Add support for using key and path transforms … -
Export Journal Feature - Building SaaS #191
In this episode, I started with cleaning up a few small items. After those warmups, we moved on to building an export feature that will allow users to take their journal entries if they want to leave the service. -
Export Journal Feature - Building SaaS with Python and Django #191
In this episode, I started with cleaning up a few small items. After those warmups, we moved on to building an export feature that will allow users to take their journal entries if they want to leave the service. -
Weeknotes (2024 week 21)
Weeknotes (2024 week 21)There have been times when work has been more enjoyable than in the last few weeks. It feels more stressful than at other times, and this mostly has to do with particular projects. I hope I’ll be able to move on soon. blacknoise I have released blacknoise 1.0. It’s an ASGI app for static file serving inspired by whitenoise. The 1.0 version number is only a big step in versioning terms, not much has happened with the code. It’s a tiny little well working piece of software which has been running in production for some time without any hickups. The biggest recent change is that I have parallelized the gzip and brotli compression step; this makes building images using whitenoise more painful because there the wait is really really long sometimes. A pull request fixing this exists, but it hasn’t moved forwards in months. I have written a longer post about it earlier this year here. Releases feincms3-cookiecontrol 1.5: Code golfing. Added backwards compatibility with old Django versions so that I can use it for old projects. Also includes optional support for Google consent management. django-fast-export 0.1.1: This is basically a repackaging of the streaming CSV view … -
Django News - Django Developers Survey 2023 Results - May 17th 2024
News Django Developers Survey 2023 Results The DSF is excited to share the results of last fall's Django Developers Survey, using detailed infographics to highlight how the community influences the future of web development. djangoproject.com pip 24.1 betas -- help us test a major upcoming change! The pip team has released pip 24.1b1, which contains a lot of significant improvements and bug fixes. pradyunsg.me Updates to Django Today 'Updates to Django' is presented by Raffaella Suardini from Djangonaut Space! Last week we had 14 pull requests merged into Django by 11 different contributors - including 3 first-time contributors! Congratulations to Adam Zahradník, R3a9670 and Alex for having their first commits merged into Django - welcome on board! Django 5.1 Alpha & Feature Freeze on May 22: by this date, all features intended for Django 5.1 must be completed and merged otherwise they will be deferred to a future release. Call to action for testers: your efforts are crucial in helping achieve a bug-free release! For more information, check out the Django 5.1 Roadmap. Django Newsletter Sponsored Ad Try Scout APM for free! Sick of performance issues? Enter Scout's APM tool for Python apps. Easily pinpoint and fix slowdowns with intelligent … -
PyGrunn: platform engineering, a python perspective - Andrii Mishkovskyi
(One of my summaries of the 2024 Dutch PyGrunn python&friends conference in Groningen, NL). There's no universally accepted definition of platform engineering. But there are some big reasons to do it. "Shift left" is a trend: a shift from pure development into more parts of the full process, like quality assurance and deployment. But... then you have an abundance of choice. What tools are you going to use for package management? Which CI program? How are you going to deploy? There are so many choices... Jenkins or github actions or gitlab? Setuptools or poetry? Etcetera. You have lots of choices: hurray! Freedom! But it takes a huge amount of time to make the choice. To figure out how to use it. To get others to use it. There of course is a need to consolidate: you can't just support everything. How do you do platform engineering? You observe. Observation: you need to be part of a community where you gather ideas and tips and possible projects you can use. You execute. Execute: you have to actually set things up or implement ideas. You collect feedback. Talk with your colleagues, see how they're using it. You really have to be open … -
PyGrunn: unifying django APIs through GraphQL - Jeroen Stoker
(One of my summaries of the 2024 Dutch PyGrunn python&friends conference in Groningen, NL). He works on a big monolythical django application. It started with one regular django app. Then a second app was added. And a third one. The UI was templates with a bit of javascript/jquery. Then a REST api was added with djangorestframework and a single page app in backbone or react. Then another rest api was added. With another rest api library. In the end, it becomes quite messy. Lots of different APIs. Perhaps one has a certain attribute and another version doesn't have it. And the documentation is probably spread all over the place. REST APIs have problems of their own. Overfetching and underfetching are the most common. Underfetching is when you have to do multiple requests to get the info you need. Overfetching is when you get a big blob of data and only need a little part of it. Then.... a new frontend app had to be build. He wanted to spend less time on defining endpoionts/serializers. And to re-use existing functionality as much as possible. At a previous pygrunn, https://graphql.org/ was suggested. What is graphql? Query language for APIs. Defined with a … -
PyGrunn: descriptors, decoding the magic - Alex Dijkstra
(One of my summaries of the 2024 Dutch PyGrunn python&friends conference in Groningen, NL). "Descriptors" are re-usable @property-like items. They implement the __get__, __set__ and __delete__ methods and possibly the __set_name__ method. See https://docs.python.org/3/howto/descriptor.html for an introduction on the python website. Most of the talk consisted of code examples: I'm not that fast a typer :-) So this summary is mostly a note to myself to check it out deeper. You can use them for custom checks on class attributes, for instance. Or for some security checks. Or for logging when an attribute is updated. This is how it looks when you use it: class Something: id = PositiveInteger() # <= this is your descriptor So usage of a descriptor is easy. The hard and tricky part is actually writing them. If you don't really need them: don't try to write them. If you write code that is used a lot, the extra effort might pay off. A funny one was an Alias descriptor: class Something: name: str full_name = Alias("name") nickname = Alias("name") something = Something() something.name = "pietje" something.name # Returns pietje something.full_name # Returns pietje, too something.nickname # Returns pietje, too -
Settings and Billing Portal - Building SaaS #190
In this episode, I worked on the settings page for the user. This was a vital addition because it allows users to access the Stripe billing portal and close their account if they no longer wish to use JourneyInbox. -
Settings and Billing Portal - Building SaaS with Python and Django #190
In this episode, I worked on the settings page for the user. This was a vital addition because it allows users to access the Stripe billing portal and close their account if they no longer wish to use JourneyInbox. -
Funding Open Source - Jeff Triplett
Jeff’s personal site and microblogRevSysuvDjangoCon Europe 2023: Yak-shaving to Where the Puck is Going to Be by Carlton Gibsondjango-vanilla-viewsneapoloitandjango-template-partialsDjango PackagesDjango Jobsawesome-django20 Django Packages That I Use in Every ProjectDjango Interview QuestionsSponsorMailtrap.io -
Django Technical Interview Questions
The technical interview is a dreaded but necessary part of landing a programming job, in this case, for web development with Django. It's important to understand that you are already … -
Django News - Django 5.0.6 released - May 10th 2024
News Django bugfix releases issued: 5.0.6 and 4.2.13 Django 5.0.6 and 4.2.13 are re-issued from Django 5.0.5 and 4.2.13 and are both bugfix additions. djangoproject.com Python 3.13.0 beta 1 released Python 3.13.0 beta 1 is the first of four beta release previews of Python 3.13. blogspot.com PSF News: PSF Board Election Dates for 2024 PSF Board elections are a chance for the community to choose representatives to help the PSF create a vision for and build the future of the Python community. This year, there are three seats open on the PSF board. blogspot.com 2023 PSF Annual Impact Report A 28-page visual report of the Python Software Foundation's actions in 2023. python.org Updates to Django Today 'Updates to Django' is presented by Raffaella Suardini from Djangonaut Space! Last week we had 14 pull requests merged into Django by 9 different contributors - including 1 first-time contributor! Congratulations to Shamil for having their first commit merged into Django - welcome on board! Bugs fixed in Django 5.0: Fixed a bug that caused a migration crash when changing a GeneratedField while renaming a field. Also addressed an issue where adding a GeneratedField before its referenced fields caused migration crashes. In Django 5.1, … -
Weeknotes (2024 week 18)
Weeknotes (2024 week 18)Google Summer of Code has begun We have a student helping out with adding async support to the Django Debug Toolbar. It’s great that someone can spend some concentrated time to work on this. Tim and others have done all the necessary preparation work, I’m only helping from the sidelines so don’t thank me. Bike to Work Two teams from my company are participating in the Bike to Work Challenge 2024. It’s what I do anyway (if I’m not working from home) but maybe it helps build others some motivation to get on the bicycle once more. Public transports in the city where I live are great but I’ll always take the bike when I can. I also went on my first mountain bike ride in a few months yesterday, good fun. JSON blobs and referential integrity The django-json-schema-editor has gained support for referencing Django models. Here’s an example schema excerpt: { ... "articles": { "type": "array", "format": "table", "title": _("articles"), "minItems": 1, "maxItems": 3, "items": { "type": "string", "title": _("article"), "format": "foreign_key", "options": { "url": "/admin/articles/article/?_popup=1&_to_field=id", }, }, }, ... } The ID field is stringly typed; using an integer directly wouldn’t work because the empty … -
Django News - New Django Ops Team Member - May 3rd 2024
News June 2024 marks 10 incredible years of Django Girls magic! 🥳✨ Join the celebration as Django Girls turns 10 🎉 and share your experiences in our survey! djangoproject.com DEFNA: Board Member Update for May 2024 Velda Kiara joins the DEFNA board, and we wish Jennifer Myers a heartfelt thank you for three years of service. defna.org Django Software Foundation Welcome our new OPS member - Baptiste Mispelon The DSF Board is pleased to introduce Baptiste Mispelon as a new member of the Ops team that maintains Django’s infrastructure. djangoproject.com Updates to Django Today 'Updates to Django' is presented by Velda Kiara from Djangonaut Space! Last week we had 11 pull requests merged into Django by 10 different contributors - including 5 first-time contributors! Congratulations to Chris Muthig, Saurabh , James Ostrander, Tim Richardson, and Cole D for having their first commits merged into Django - welcome on board! Django 5.0.5 got a bug fix. You can now import aprefetch_related_objects from django.db.models Djangonaut Space Session 2 is still open and accepting applications. Read more about it here and apply. Django Newsletter Wagtail CMS Get even more organized with Wagtail 6.1 An overview of what's new in Wagtail 6.1. wagtail.org How … -
Building Reusable Components in Django
This tutorial looks at how to build server-side UI components in Django. -
Renewing Let's Encrypt Certificates with NGINX Unit
Recently, I moved the DjangoTricks website and started PyBazaar on servers with Nginx Unit. One thing that was left undone was SSL certificate renewals. Let's Encrypt has special certbot parameters for renewing certificates for websites on Apache or Nginx servers, but they don't work out of the box with the Nginx Unit. In this blog post, I will tell you how to do that. The certificate bundle Nginx Unit doesn't use the fullchain.pem and privkey.pem generated by certbot directly from the location where they were generated. Instead, one has to create a bundle (like bundle1.pem) by concatenating them and then uploading it to the Nginx Unit configuration endpoint. The bash script For that, I created a bash script: #!/usr/bin/env bash SECONDS=0 CRON_LOG_FILE=/var/webapps/pybazaar/logs/renew_certificate.log echo "=== Renewing Letsencrypt Certificate ===" > ${CRON_LOG_FILE} date >> ${CRON_LOG_FILE} echo "Renewing certificate..." >> ${CRON_LOG_FILE} certbot --renew-by-default certonly -n --webroot -w /var/www/letsencrypt/ -m hello@pybazaar.com --agree-tos --no-verify-ssl -d pybazaar.com -d www.pybazaar.com echo "Creating bundle..." >> ${CRON_LOG_FILE} cat /etc/letsencrypt/live/pybazaar.com/fullchain.pem /etc/letsencrypt/live/pybazaar.com/privkey.pem > /var/webapps/pybazaar/unit-config/bundle1.pem echo "Temporarily switching the Unit configuration to a dummy one..." >> ${CRON_LOG_FILE} curl -X PUT --data-binary @/var/webapps/pybazaar/unit-config/unit-config-pre.json --unix-socket /var/run/control.unit.sock http://localhost/config echo "Deleting old certificate from Nginx Unit..." >> ${CRON_LOG_FILE} curl -X DELETE --unix-socket /var/run/control.unit.sock http://localhost/certificates/certbot1 echo "Installing … -
Self-Hosted Open Source - Michael Kennedy
TalkPython to Me Podcast and CoursesHTMX + Django: Modern Python Web Apps, Hold the JavaScript CourseUmamilistmonkOpen Source Software Products for Every Business FunctionElestHigh Availability Percentage CalculationPostHogbtopSponsorMailtrap.io -
Generating Fake Django Model Instances with Factory Boy
As you might know, I am developing PyBazaar, a Python Developer Marketplace. For a project of that scope, I need to create hundreds or thousands of data entries to ensure that everything works as expected. Factory Boy is a tool that allows me to create model instances in batches, and this blog post is about it. The benefits of using Factory Boy By creating a bunch of fake entries, I can achieve the following: Work on list and detail representation and styling. Work on and try functionality like filters, sorting, and pagination. Check and improve performance with loads of data entries. Create dummy data for unit or functional tests. Factory Boy seemed like a pretty complex package, so I want to simplify things and introduce you to all the necessary parts for creating a fake model instances. Model preparation At PyBazaar, I have users with profiles, job offers, and resources that can be faked in batch. The related categories are predefined and don't need to be faked. To make it possible to distinguish between real and fake entries, I added a new boolean field is_fake to all those models that I can create in batch: # For testing and debugging … -
Generating Fake Django Model Instances with Factory Boy
As you might know, I am developing PyBazaar, a Python Developer Marketplace. For a project of that scope, I need to create hundreds or thousands of data entries to ensure that everything works as expected. Factory Boy is a tool that allows me to create model instances in batches, and this blog post is about it. The benefits of using Factory Boy By creating a bunch of fake entries, I can achieve the following: Work on list and detail representation and styling. Work on and try functionality like filters, sorting, and pagination. Check and improve performance with loads of data entries. Create dummy data for unit or functional tests. Factory Boy seemed like a pretty complex package, so I want to simplify things and introduce you to all the necessary parts for creating a fake model instances. Model preparation At PyBazaar, I have users with profiles, job offers, and resources that can be faked in batch. The related categories are predefined and don't need to be faked. To make it possible to distinguish between real and fake entries, I added a new boolean field is_fake to all those models that I can create in batch: # For testing and debugging … -
How to Use ModelAdmin with Wagtail CMS v6+
The powerful ModelAdmin feature of Wagtail CMS has been removed as of Wagtail v6. The Wagtail team now encourages the use of SnippetViewSet, which includes advanced features like bulk actions. Here is an official migration guide from ModelAdmin to Snippets. However, if you have extensive custom code … Read now -
Django: An admin extension to prevent state leaking between requests
Here’s a small protection I added to a project a few years ago. I was considering it again since I saw a similar potential bug in a Django middleware. Long live the ModelAdmin instances Django’s admin site is configured by the ModelAdmin class. You register this per model: from django.contrib import admin from example.models import Book @admin.register(Book) class BookAdmin(admin.ModelAdmin): fields = [ "title", "special", ] The @admin.register() decorator calls the AdminSite.register() method, which creates an instance of the ModelAdmin class (which can also be auto-generated): class AdminSite: ... def register(self, model_or_iterable, admin_class=None, **options): ... for model in model_or_iterable: ... # Ignore the registration if the model has been # swapped out. if not model._meta.swapped: ... # Instantiate the admin class to save in the registry self._registry[model] = admin_class(model, self) So, ModelAdmin instances are created once at import time and reused between all requests. That means it’s not safe to use ModelAdmin instance variables to store state because they can affect later requests. (And if you run your project with a threaded WSGI server or ASGI server, ModelAdmin instance variables may be read by concurrent requests!) This may be a surprising revelation if you have come from PHP, which has a … -
Django News - Djangonaut Space 2024 Session 2 - Apr 26th 2024
News Djangonauts Space Session 2 Applications Open! Applications are now open for the next 8-week group mentoring program, where individuals will work self-paced in a semi-structured learning environment. If you want to work with Jeff on Django Packages, he is mentoring a team this session. djangonaut.space Django Developers Survey 2023 Results The results of the Django Developers Survey 2023, which is a collaborative effort between the Django Software Foundation and PyCharm, are in! jetbrains.com 10th anniversary of Django Girls Survey Speaking of surveys, Django Girls and JetBrains have teamed up to celebrate the 10th anniversary of Django Girls with a survey that is complete with prizes. jetbrains.com Updates to Django Today 'Updates to Django' is presented by Raffaella Suardini from Djangonaut Space! Last week we had 9 pull requests merged into Django by 9 different contributors - including 3 first-time contributors! Congratulations to Mohammad Kazemi, Jason K Hall and Eyal Cherevatsky for having their first commits merged into Django - welcome on board! Coming in Django 5.0.5, a bug fix with GeneratedField, preventing crashes when applying migrations, especially those involving the argument db_index=true. Application for Djangonaut Space Open 🚀 I'm thrilled to announce that the second session of Djangonaut Space … -
South: migraciones inversas
Una vez que pruebas las migraciones de bases de datos es muy complicado adaptarse a trabajar sin ellas. Cuando empezamos un proyecto Django uno de los primeros "requisitos" es instalar South para que haga todo este sucio trabajo. Y no todo es bonito... normalmente estás obligado a ejecutar la migración para probar si funciona o no. Y si no funciona, sigues obligado a corregirla y volver a correr otra migración para arreglar la anterior que no funcionaba. Y este proceso puede repetirse varias veces a lo largo del desarrollo de un proyecto, con lo que al final acabas con un número muy alto de migraciones, de las cuales cierta cantidad son parches ínfimos para arreglar cualquier pequeño fallo. Y si a todo esto le sumamos un equipo de trabajo, un repositorio de versiones y todo el flujo de trabajo que conlleva, puede ser una fuente importante de conflictos. South schemamigration --auto --update Imagino que a petición de la gente, en South han pensado en ello y han implementado una sencilla funcionalidad que resuelve todo este entuerto y hace más llevadero tanto el probar los cambios como la resolución de esos pequeños fallos que puedan surgir sin llenar de paja nuestro … -
Django and memcache: clear cache keys
Let's play Django with Memcached. As the great framework Django is, it's so easy to activate any kind of cache in your project. Memcached is one of the options, but you can also work with DatabaseCache, FileBasedCache, LocMemCache, MemcachedCache, DummyCache (a kind of non-cache very useful for devel/test enviroments) or - of course - your own CustomCache if you want. Activating cache It's too easy to activate the cache feature, it's enough to set the preferences in settings, install python-memcached in your enviroment (in case you will use MemcachedCache), and not much more to do. A couple of examples: 1. Basic FileBasedCache settings: # settings.py CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', 'LOCATION': '/var/tmp/django_cache', } } 2. MemcachedCache settings: # settings.py CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } 3. Depending on the enviroment you can use MemcachedCache and DummyCache: # settings.devel.py CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', } } # settings.production.py CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } Setting the places where cache will act Now that we have our project with a configured kind of cache, we must to say where and when to activate it. There are multiple ways to do it …