Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django: The perils of string_if_invalid in templates
Django’s template engine has a string_if_invalid option that replaces missing variable lookups with a string of your choice: TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", # ... "OPTIONS": { # ... "string_if_invalid": "MISSING VARIABLE %s", }, } ] The %s will be replaced with the name of the missing variable. This exists as a debugging aid to track down missing variables, but the documentation comes with a hefty warning: For debug purposes only! While string_if_invalid can be a useful debugging tool, it is a bad idea to turn it on as a 'development default'. Many templates, including some of Django's, rely upon the silence of the template system when a nonexistent variable is encountered. If you assign a value other than '' to string_if_invalid, you will experience rendering problems with these templates and sites. Generally, string_if_invalid should only be enabled in order to debug a specific template problem, then cleared once debugging is complete. (This warning was added in 2006 by Russell Keith-Magee in commit 73a6eb8.) Despite the admonition, there are some recommendations out there to enable the option permanently in tests, including pytest-django’s --fail-on-template-vars option and from myself in a post last year. I’ve recently been exploring ways to prevent … -
Building a Future-Proof Platform with Block-Driven CMS
In a previous blog post, I discussed the advantages of using django CMS to create a Multi-Distribution Channel CMS. To achieve the flexibility required to repurpose content across various channels, it is essential to establish a clear separation between the rendered output (usually HTML) and the underlying data. Django, Django CMS, and django-filer provide the necessary components to construct a customized multi-channel publishing platform tailored to your business needs. Many organizations find themselves outgrowing their page-driven CMS or limited by their current system, prompting them to embark on the challenging path of re-platforming. In this article, I will outline a content architecture that allows for the development of a future-proof platform, capable of evolving as required. This approach is particularly beneficial when managing and displaying complex related data and handling massive data collections to a large audience. Defining the Scenario: ACME Publisher For the purpose of illustration, let’s consider a fictional publisher named ACME, which operates a significant online magazine/newspaper. ACME’s online presence comprises a collection of articles published in various sections. Each article is composed of one or more blocks, such as decorated text, images, slideshows, videos, content promotions, calls to action, and more. ACME, like other publishers, faces … -
Django News - Django bugfix release: 4.2.4 - Aug 4th 2023
News Django bugfix release: 4.2.4 The 4.2.4 bugfix release fixes three different issues. As always, updating to the latest version of Django is highly recommended. djangoproject.com Wagtail 5.1 gets a bit greener and leaner Notes on the latest Wagtail release that focuses on improving performance and reducing Wagtail's carbon footprint. wagtail.org Python Steering Council accepts PEP 703 and plans to remove the GIL The Python Steering Council has informally accepted PEP 703 and outlined their long-term plan to formally drop Python's Global Interpreter Lock (GIL) in a future Python version. python.org Announcing Python Software Foundation Fellow Members for Q1 2023! The PSF is pleased to announce its first batch of PSF Fellows for 2023! blogspot.com Updates to Django From Django Review and Triage Team Member Sarah Boyce. Last week we had 8 pull requests merged into Django by seven different contributors. No first-time contributors this time, so let's celebrate some of our relatively new contributors for coming back! Congratulations to Olivier Tabone for their 2nd, Bruno Alla for their 3rd, and John Parton for their 3rd PR merged into Django! Django 4.2.4 was released earlier this week. While many people are involved in a release, especially the Fellows, I want … -
Launch Preparation - Building SaaS #167
In this episode, I started working through the set of issues that I previously identified as necessary to complete before launching the service on Heroku. We add history tracking, soft deletion for the user model, and integration with SendGrid. -
Launch Preparation - Building SaaS with Python and Django #167
In this episode, I started working through the set of issues that I previously identified as necessary to complete before launching the service on Heroku. We add history tracking, soft deletion for the user model, and integration with SendGrid. -
Boost Your Django DX - Adam Johnson (Ep105 Replay)
Personal websiteBoost Your Django DX - Preorder the New BookMalcolm Tredinnick Memorial PrizeDjango Technical Board Election ResultsFinding the new (and old) contributors to Django 4.0django-upgradedjango-browser-reloadToday’s Django Security Release Deconstructed (4.0.1, 3.2.11, and 2.2.26)SQLite function optimization and PRSignal Receiver Functions tidy up and PROne Line Django Docs Change and PRSupport the ShowLearnDjango.comButtonDjango News newsletter -
Weeknotes (2023 week 30)
Weeknotes Async Django I have used Django Channels successfully in a few projects from 2017 to 2019. A few months back I have worked with Starlette. And now I have finally started digging into using Django itself with an ASGI server, and not just for one or two views but also including the middleware stack etc since I also need authentication, not just an endpoint forwarding requests to a remote server. I have looked at Granian, an RSGI/ASGI server written in Rust. But for now I am using uvicorn. Django truly has come a long way but there’s much left to do. Django 5.0 is looking great already, but 4.2 misses many pieces still. I am really really glad Django wants to stay backwards compatible but I wish I could wave a magic wand and upgrade everything to async. Adding a prefixes everywhere for the async version is certainly a good compromise and probably the way to go but it’s just not that nice. I have been playing around with making feincms3’s applications middleware async compatible because I want the full middleware stack to be async. The code is already released but undocumented and not even mentioned in the changelog. … -
Django News - Django/PyCharm Campaign Extended to July 31st - Jul 28th 2023
News Django + PyCharm Campaign Extended to July 31st You get a 30% discounted year of PyCharm, AND the Django Software Foundation gets 100% of the proceeds. Plus, get one free month of access to JetBrains Academy, which has courses like Intro to Django, SQL, Git, and more! jetbrains.com Updates to Django Updates to Django From Django Review and Triage Team Member Sarah Boyce. Last week we had 16 pull requests merged into Django by 10 different contributors - including 4 first time contributors! Congratulations to Mariana, Nicolò Intrieri, Vyacheslav Dmitriev and Michel Alexandre Salim for having their first commits merged into Django - welcome on board! Now in 5.0, you will notice some color updates to the Django admin light theme. This has improved color contrast to make the admin more accessible #34036. Also, Bhuvnesh has been working on allowing moving a model between apps as part of Google Summer of Code. This is now being tested and so if you have any ideas of scenarios to test, please engage in the discussion on the forum for this feature. For those who are not already familiar with the forum, Django Internals often has discussions involving the current development of … -
Sentry Setup - Building SaaS #166
In this episode, I finished the email sending job, then determined which issues will be needed before launching the product. Once we crafted the short list, I added an integration with Sentry. -
Sentry Setup - Building SaaS with Python and Django #166
In this episode, I finished the email sending job, then determined which issues will be needed before launching the product. Once we crafted the short list, I added an integration with Sentry. -
How ruff changed my Python programming habits
How ruff changed my Python programming habits ruff isn’t just a faster replacement for flake8, isort and friends. With other Python-based formatters and linters there’s always a trade off between development speed (waiting on git commit is very boring) and strictness. ruff is so fast that enabling additional rules is practically free in terms of speed; the only question is if those rules lead to better, or maybe just to more correct and consistent code. I have long been using pre-commit, and even longer flake8, black, isort. I have written a piece about flake8 and the value of standards almost 9 years ago and have continued moving in the mentioned direction ever since. These days I have enabled a wide variety of rules. I’m not sold on all of them (looking at you, pylint) and I’m definitely not of the opinion that rules which I’m not using currently are worthless. I didn’t even know most of these rules before starting to use ruff, and ruff making them easy and painless to use (without a measureable performance penalty) has certainly lead to me annoying my coworkers with a growing set of enabled rules. Rules The current ruleset and some justifications for … -
Easy as Pie: Setting Up Dokku for Your Personal Project
IntroductionApplication Platform in the CloudAre you looking for a simple and efficient way to deploy your personal project without the complexities of traditional server management? Look no further than Dokku! In this tutorial, we’ll walk you through the seamless process of setting up Dokku for your personal project. By the end of this article, you’ll be amazed at how easy it is to get your application up and running in no time.What is Dokku?Dokku is a lightweight open-source platform that allows you to deploy and manage applications using Docker containers. Often referred to as “Docker-powered Heroku,” Dokku takes the simplicity of Heroku’s deployment model and combines it with the flexibility and power of Docker. With Dokku, you can deploy web applications, microservices, and various other types of projects effortlessly.PrerequisitesBefore we begin, make sure you have the following prerequisites in place:A personal project: Prepare your web application or project that you want to deploy using Dokku.A server: You will need a remote server or a VPS (Virtual Private Server) with a fresh installation of Ubuntu 20.04 or later.A domain: Purchase a domain name (e.g., example.com) from a domain registrar of your choice.DNS settings: Ensure you have access to your domain’s DNS … -
Weeknotes (2023 week 29)
Weeknotes I have mainly done work in private projects this week. Not much to talk about. Except for the ZIP file content-type bug which was interesting enough to justify its own blog post. Releases django-cabinet 0.13: I converted the package to use ruff, hatchling; started running CI tests using Python 3.11. The internals of the Django admin’s filters have changed to allow multi-valued filters, this has required some changes to the implementation of the folder filter. I opted to using a relatively ugly django.VERSION hack; but that’s not too bad since such branches will be automatically removed by the awesome django-upgrade. I would have tried finding other ways in the past but now that old compatibility code can be removed by a single run of django-upgrade (respectively pre-commit) there really is no point to doing it in a different way. -
Django News - DjangoCon US and AU 2023 programs are up! - Jul 21st 2023
News Python Web Conf 2023 Talks + Tutorials available on YouTube Watch 80 talks, tutorials, and socials from Python Web Conf 2023 on Six Feet Up's YouTube channel. Explore videos about Python, Django, Kubernetes, AI/ML, Big Data, CI/CD, Serverless, Security, Climate Tech, and more. youtube.com PyCharm & DSF Campaign 2023 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 proceeds. Plus, get one free month of access to JetBrains Academy, which has courses like Intro to Django, SQL, Git, and more! djangoproject.com Django Software Foundation DSF Board monthly meeting, July 14, 2023 Meeting minutes for DSF Board monthly meeting, July 14, 2023. djangoproject.com Updates to Django Updates to Django From Django Review and Triage Team Member Sarah Boyce... Last week we had 20 pull requests merged into Django by 12 different contributors - including 5 first time contributors! Congratulations to Tushar, Ryan Chausse, Cauê Thenório, Amir Karimi and Priyank Panchal for having their first commits merged into Django - welcome on board! Some highlights include: - updating QuerySet.bulk_create() to retrieve primary keys when updating conflicts (#34698) - adding documentation on … -
Email Templates - Building SaaS #165
In this episode, we added the prompt email that will be the primary way of connecting to users for our email-based journaling service. I spent a fair amount of time thinking about copy writing to craft a compelling email that will resonate with users. Also, I made a bunch of silly mistakes and to keep correcting myself, so this is a good example of programming humility too. -
Email Templates - Building SaaS with Python and Django #165
In this episode, we added the prompt email that will be the primary way of connecting to users for our email-based journaling service. I spent a fair amount of time thinking about copy writing to craft a compelling email that will resonate with users. Also, I made a bunch of silly mistakes and to keep correcting myself, so this is a good example of programming humility too. -
Django Deployments - Eric Matthes (Ep108 Replay)
django-simple-deployPython Crash Course recommended readingsPython Crash Course bookPython on Azure 4-Part Series with CarltonLocust.io: Open source load testing toolShameless PlugsLearnDjango.comButtonDjango News newsletter -
Django REST Framework Authentication with Auth.js
This tutorial looks at how to add authentication to Django REST Framework and integrate it with Auth.js. -
Serving ZIP files using Django
Serving ZIP files using Django I have generated ZIP files on the fly and served them using Django for a time. Serving ZIP files worked well until it didn’t and browsing StackOverflow etc. didn’t produce clear answers either. The development server worked fine, but gunicorn/nginx didn’t. In the end, I had to change content_type="application/zip" to content_type="application/x-zip-compressed". I still don’t know what changed and I have only theories why that’s necessary, but maybe it helps someone else. Sometimes it’s better to be dumber about it. -
Django News - 10 Merged PRs into Django Core This Week! - Jul 14th 2023
News Python 3.12.0 beta 4 released Python 3.12.0 beta 4 is the final of four beta release previews. We strongly encourage maintainers of third-party Python projects to test with 3.12 during the beta phase and report issues found to [the Python bug tracker (https://github.com/python/cpython/issues) as soon as possible. blogspot.com Updates to Django Updates to Django From Djangonaut Program Member Anvansh Singh. Last week, the Django community experienced 10 merged pull requests, accompanied by the exciting debut of remarkable first-time contributors Gregor Jerše and davidolz. Their impactful entrance is warmly embraced by the community! Gregor Jerše made a significant first contribution by improving accessibility for screen reader users, associating form fields with their help text using aria-describedby. This change enhances navigation and understanding of the form. If you have a custom aria-describedby attribute defined in a form widget, please read the updated documentation to take advantage of the improved accessibility for Django 5.0. Other notable contributions included Mariusz Felisiak's closure of a 15-year-old ticket (#9602) by adding a new method AdminSite.get_model_admin which returns an admin class for the given model class. Amazing! Want to make a contribution? Head over to https://code.djangoproject.com/query, pick a ticket, and start working. You may be the … -
Weeknotes (2023 week 28)
Weeknotes (2023 week 28)Releases html-sanitizer 2.2: Made the sanitizer’s configuration initialization more strict. Strings cannot be used anymore in places where the sanitizer expects a set (resp. any iterable). It’s useful that strings are iterable in Python and I wouldn’t want to change that, but the fact that ("class") is a string and not a tuple makes me sad. The fact that tuples are created by , and not by () will always trip up people. feincms3-language-sites 0.1: The version number is wrong but whatever. I’m certainly happy with the state of things. The big change in 0.1 is that Page.get_absolute_url no longer generates protocol-relative URLs. Depending on the value of SECURE_SSL_REDIRECT it automatically prepends either http: or https:. django-authlib 0.15: django-authlib’s admin Single Sign On module now supports a hook to automatically create staff users when a matching user doesn’t exist already. I don’t plan to use this functionality myself and I have recommended people to implement the functionality themselves using the tools in django-authlib if they need it, but the change was so small and well-contained that adding it to the core made sense to me. pipx inject We learned that pipx seems to remember injected packages even … -
Django: Clean up unused code with Vulture
As projects evolve, old functionality gets removed. Often such deletions are incomplete, leaving in their wake unused functions, classes, and other code objects. Unused code is clutter that brings no joy: it hinders comprehension, taxes codebase-wide quality improvements, and can sometimes lead to errors if later used. In an ideal world, test coverage data would reveal unused code, since a perfect test suite has 100% coverage of all features. But most projects don’t live in the ideal world, so unused code detectors exist. These tools use static analysis and heuristics to find probably-unused code, which you can then decide whether to remove. Such tools cannot be certain because Python makes it impossible to be sure that an object isn’t used. Objects can always be referenced with dynamically-constructed names, such as through globals(): def dynamic_about(request): page = request.GET.get("page", "company") if page not in {"company", "team", "..."}: page = "company" return globals()[f"about_{page}"](request) def about_company(request): ... Normally projects don’t have much dynamic dispatch like this, but it’s always a possibility. That’s why you need to review findings from an unused code detector before acting on it. Enter the Vulture Vulture is a popular unused code detector for Python. It analyzes the Abstract Syntax … -
FastAPI with Async SQLAlchemy, SQLModel, and Alembic
This tutorial looks at how to configure SQLAlchemy, SQLModel, and Alembic to work with FastAPI asynchronously. -
Django News - Django security releases issued: 4.2.3, 4.1.10, and 3.2.20 - Jul 7th 2023
News Django security releases issued: 4.2.3, 4.1.10, and 3.2.20 These releases address a new security issue. All users of Django are encouraged to upgrade as soon as possible. djangoproject.com Announcing the 2023 Python Software Foundation Board Election Results! Congratulations to the 5 new members. blogspot.com PyCharm & DSF Campaign 2023 In collaboration with JetBrains, Django Software Foundation (DSF) is running a fundraiser from July 3rd to July 23rd, offering a 30% discount on a year of PyCharm, with all proceeds supporting DSF. Purchasing also grants a free month of JetBrains Academy access with courses like Django, SQL, and Git. djangoproject.com Updates to Django Updates to Django From Django Review and Triage Team Member Sarah Boyce... Last week we had a massive 20 pull requests merged into Django by 11 different contributors - including 2 first time contributors! Congratulations to Jonathan Weth and Cerebro Cerberus for having their first commits merged into Django - welcome on board! Changes this week include adding support for GDAL 3.7 and dropping support for GDAL 2.2 and 2.3. Support for GEOS 3.6 and 3.7 has also been dropped. These are stated in the backwards incompatible changes of 5.0. Also, from Django 5.0, the force_insert argument … -
Django REST Framework (Replay)
DRF Google GroupDjangoCon 2018 Talk: Finally Understand User Authentication in DRFDRF Official Documents: Authenticationdjango-cors-header packageSwagger vs OpenAPIAPI StarStarletteGraphQL vs RESTSPONSORING OPTIONSDRF SponsorsDjango Software FoundationSHAMELESS PLUGSLearnDjango.comCarlton's website Noumenal