Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Hire for Floors, not Ceilings
When you’re hiring, try not to get caught in the trap of evaluating candidates based on their best possible performance. Look instead for consistency: reliable results in variable conditions, the ability to deliver predictably with consistent quality, and so forth. -
Composition over inheritance: The case for function-based views
Composition over inheritance: The case for function-based views A recent conversation with Carlton on Mastodon prompted me to write down some of my thoughts re. function- vs class-based views in Django. The early days When I started using Django some time after 0.96 and 1.0 all views were function based. Except when you added a class with a def __call__() method yourself – that was always possible but not really comparable to today’s class-based views. The introduction of class-based views Class based views (both generic versions and the base View) were introduced to Django in 2010. Judging from the ticket tracker the main motivation was to avoid adding yet another argument to the generic function-based views (GFBV) which we’re available in Django back then. The GFBV’s argument count was impressive. Two examples follow: def object_detail(request, queryset, object_id=None, slug=None, slug_field='slug', template_name=None, template_name_field=None, template_loader=loader, extra_context=None, context_processors=None, template_object_name='object', mimetype=None): ... def archive_month(request, year, month, queryset, date_field, month_format='%b', template_name=None, template_loader=loader, extra_context=None, allow_empty=False, context_processors=None, template_object_name='object', mimetype=None, allow_future=False): ... The GFBVs where immediately when GCBVs were introduced and later removed in 2012. Class-based views have to be adapted by calling the View.as_view() method; as_view() returns arguably the thing which is viewed (sorry) as the view by … -
Django News - Python 3.12.0rc1 and Generative Agents oh mai - Aug 11th 2023
News Python 3.12.0 release candidate 1 released Python 3.12.0rc1 is the first release candidate of Python 3.12, with a final version expected on 2023-10-02. Maintainers are urged to ready their projects for 3.12 compatibility, though this preview is not advised for production use. blogspot.com The Python Software Foundation 2022 Annual Impact Report The Python Software Foundation's 2022 Annual Impact Report highlights a year where they welcomed a new Executive Director, reconvened for the first in-person PyCon US since 2019, expanded membership options, awarded $215K in grants, incorporated PyLadies chapters into their fiscal sponsorship program and much more. python.org Python Software Foundation News: Announcing Our New PyPI Safety & Security Engineer! Mike Fiedler joins the PSF as the inaugural PyPI Safety & Security Engineer, boasting 15 years of Python experience and a recent role as a PyPI Maintainer. See from Mike's follow-up post too. blogspot.com Updates to Django Updates to Django This week the updates have been curated by Yemisi, from the Djangonaut Space contributor program. You can find Yemisi on Twitter @Oluwayhemisi1 or LinkedIn Oluwayemisi Ismail. In the previous week, we had 17 pull requests merged into Django by 11 different contributors. Notably, we're thrilled to acknowledge the participation of … -
Practical Business Jinja
Inspired by the Practical Business Python blog this Python Frederick meetup will cover how to automate document creation using Python-docx and Jinja. -
Practical Business Jinja
Inspired by the Practical Business Python blog this Python Frederick meetup will cover how to automate document creation using Python-docx and Jinja. -
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 …