Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Speaking at Python Web Conf
During the week of March 21-25 at Python Web Conf I'm giving my first public conference talk in three years. I'm both excited and apprehensive about returning to the speaker's podium. To me, public speaking is like a roller coaster ride. The climb up the first hill (or minute when it comes to speaking) is absolutely terrifying. Then as soon as the car accelerates (or I begin to speak), endorphins kick in. I go from struggling not to visibly tremble from fear to shaking with excitement. Hint: Use code Speaker15@PWC2022 to get 15% off your ticket costs. The talk I'm going to give is titled, "Confessions of Joe Developer". Here's the synoposis: Over the course of 17 years of professional Python development at Octopus Energy, NASA, and various agencies, Daniel Roy Greenfeld has picked up a lot of easy tricks stolen from the best and brightest in the software community that make him look good in front of his peers and colleagues. And now, at great risk to his career and reputation, he is going to show you how he does it. What that description doesn't tell you is that I came up with the core concepts of that talk … -
Announcing WhiteNoise 6
WhiteNoise is a simple solution to serving static assets. It lets you skip configuring a separate web server for your static assets, and serve them straight from Django. It’s a brilliant tool. I’ve used it for years on various projects, and I’ve recommended it many times, and mentioned it in several blog posts. WhiteNoise was created by Dave Evans in 2013. I’ve met Dave several times at the London Django Meetup. Recently the project’s maintenance was getting a bit backlogged, so I volunteered to help and Dave accepted :) I got to work adding support for modern Python and Django versions, dropping old ones, and merging in a few feature requests. I just released these accumulated changes as version 6.0.0. Nothing drastic has changed for the major version bump - most users should not be affected. setuptools’s python_requires field also ensures users on outdated Python versions still install older WhiteNoise versions. But there are enough changes that it felt like a major number was needed, and version numbers are cheap. Here are the changelog entries for 6.0.0: Drop support for Python 3.5 and 3.6. Add support for Python 3.9 and 3.10. Drop support for Django 1.11, 2.0, and 2.1. Add … -
Working with Static and Media Files in Django
This article looks at how to work with static and media files in a Django project, locally and in production. -
Setting Your Sites
Full show notes are available at https://www.mattlayman.com/django-riffs/16. -
Episode 16 - Setting Your Sites
On this episode, we look at how to manage settings on your Django site. What are the common techniques to make this easier to handle? Let’s find out! Listen at djangoriffs.com or with the player below. Last Episode On the last episode, we dug into sessions and how Django uses that data storage technique for visitors to your site. How Is Django Configured? To run properly, Django needs to be configured. -
typing.Protocol Across Python Versions
How to seamlessly support typing.Protocol on Python versions older and newer than 3.8. At the same time. -
Django News - Django security releases issued: 4.0.2, 3.2.12, and 2.2.27 - Feb 4th 2022
News Django security releases issued: 4.0.2, 3.2.12, and 2.2.27 Multiple security updates in this release. We encourage all users of Django to upgrade as soon as possible. djangoproject.com Want to host DjangoCon Europe 2023? If you have ever wanted to host and run DjangoCon Europe, the DSF welcomes your proposal. djangoproject.com Black (22.1.0) is out of beta At long last, Black is no longer a beta product! This is the first non-beta release and the first release covered by a new stability policy. Django has committed to incorporating Black once this milestone was reached per DEP 8. github.com Google sponsors Wagtail CMS's next-generation web content management experience When Google saw the roadmap of enhancements ahead for Wagtail, they realized how much their team will benefit and decided to provide $150,000 of corporate sponsorship to accelerate the development effort. prnewswire.com Open Source Credit Survey The University of Vermont team is conducting a survey about how people receive credit for the tasks they do as part of open source projects. dev.to Heads up: pip-compile fails with pip 22.0 pip==22.0 broke pip-tools. github.com Trends and Insights Trends and Insights for the first week of February 2022 🗑 Apple is officially removing Python 2.7 … -
Admin Interface For PDFs - Building SaaS with Python and Django #126
In this episode, I need tools to inspect some PDF reports that I’m building that customers of my homeschool app will use at the end of the school year. I build the admin tools that allow me to see these PDFs quickly. -
Admin Interface For PDFs - Building SaaS #126
In this episode, I need tools to inspect some PDF reports that I’m building that customers of my homeschool app will use at the end of the school year. I build the admin tools that allow me to see these PDFs quickly. -
Django Testing and Debugging - Karen Tracey
Karen Tracey at Cactus groupDjango 1.1 Testing and Debugging Caktus Group: Auto Scaling Online SurveyKaren joining the DSF BoardSupport the ShowThis podcast does not have any ads or sponsors. To support the show, please consider purchasing a book, signing up for Button, or reading the Django News newsletter. -
Developing a Values Interview Question
How do you develop an interview question that measures a core value? -
Save a Django Query to the Database
I found a StackOverflow question on saving a Django query to the database, but I was left super unclear on what to do. There’s all this talk about… -
Save a Django Query to the Database
I found a StackOverflow question on saving a Django query to the database, but I was left super unclear on what to do. There’s all this talk about pickling and serialization that I’m sure makes a ton of sense to someone smarter than me. The current answer is old, however, and in 2022, I found another solution: turning a dict into JSON. Plus, I found a way to make it work with my htmx live search, allowing me to view the results of my query on the front end of my site (read: pretty) to double-check that things look okay before saving. I’ll show you what I did below. I believe pickling still works, so at the end I will show some more thoughts there. models.py - example database structure class Transaction(models.Model): id = models.CharField(max_length=24, primary_key=True) date = models.DateField(null=False) amount = models.IntegerField(null=False) info = models.CharField() account = models.ForiegnKey(Account, on_delete=models.SET_NULL, null=True) category = models.ForeignKey(Category, on_delete=models.SET_NULL, null=True, blank=False, default=None) class Account(models.Model): name = models.CharField() email = models.EmailField() class Category(models.Model): name = models.CharField(unique=True) class Rule(models.Model): category = models.ForeignKey(Category, on_delete=models.SET_NULL, blank=False, null=True, default=None) criteria = models.JSONField(default=dict) # this will hold our query My models store financial transactions, the category the transaction fits into (e.g., … -
Django News - DjangoCon Europe 2022 - Jan 28th 2022
News Announcing DjangoCon Europe 2022 DjangoCon Europe 2022 is back again and it’s going to be five full days of talks, tutorials, and sprints September 21-25, 2022. djangoproject.com Django Styleguide Survey HackSoft is running a survey on current Django style usage which will be used to update its open source Django Styleguide. hacksoft.io Trends and Insights Trends and Insights for January So much happens on social media that doesn't always get covered in traditional articles, and we wanted to experiment with an occasional Trends and Insights section. Let us know if you like the idea and what you think. We might make it a more permanent part of our newsletter if it's well-received. 🐍 CPython's main branch now compiles to WebAssembly, which means that Python will run natively in your web browser. Check out Katie Bell's "How to run Python in the browser" talk from LCA 2022. 🥚 Dustin Ingram shared some packaging insights that, as of December 2021, less than 1% of all uploading PyPI packages include .egg files. Python eggs are effectively deprecated. 🧪 Jamie Matthews shared a nice PyQuery snippet that makes testing for exact text easier in a reply thread about Django Template tips, tricks, and … -
Ordering Existing Models - Building SaaS with Python and Django #125
In this episode, we built out a customer requested feature of adding order of grade levels within the school year of my homeschool app. This will allow users to change the display of crucial pages within the app. -
Ordering Existing Models - Building SaaS #125
In this episode, we built out a customer requested feature of adding order of grade levels within the school year of my homeschool app. This will allow users to change the display of crucial pages within the app. -
How to Set Up Source Maps with Django
Source maps are files that map your minified CSS or JavaScript back to the original code. They allow you to use your browser’s development tools to debug minified code as if it were the original. In this post we’ll look at how source maps fit into Django’s static files infrastructure, including a couple recent changes I made to Django to better support them. We’ll look at using a JavaScript source map, but everything applies equally to CSS source maps. Alrighty, let’s dig in. Directory Layout Let’s look at an example project using source maps to see how they fit into Django’s infrastructure. This project demonstrates a static file setup that works well for most projects. The project has three directories for “static files” with different roles, all in the root of repository: frontend/, which contains the source CSS and JavaScript files. Django doesn’t use this directory at all. Frontend tools, like bundlers, should process the source files in frontend/ and place output files in the next directory, static/. This provides a clear “hand off”. static/, which contains static files for Django to manage. This is in the STATICFILES_DIRS setting: STATICFILES_DIRS = [BASE_DIR / "static"] static_root/, which is created by Django’s … -
For hire
As I write this it’s the evening of January 23, 2022. A little over two weeks ago I gave notice at my now-former employer, and as of two days ago I am officially on the job market. If you already know me and are interested in talking about an opportunity, please get in touch. Or if you want to know a bit more first, read on… Who I am It’s a bit tricky to pin down when … Read full entry -
Django Rest Framework authentication: the easy way
In this tutorial you'll learn how to implement Django Rest Framework authentication in your web application by leveraging the built-in Django session framework. This approach is way simpler (and secure) than other popular methods such as JWT, and has only one requirement: your frontend (think Vue.js, React, ...) and your backend should be served by the same domain. I created an example project on GitHub you can use to follow along with this tutorial. Table of Contents Why you should avoid JWT for Django Rest Framework authentication Django Rest Framework settings Django Rest Framework authentication endpoint Test authentication using HTTPie A new endpoint to retrieve the user profile Test the user profile endpoint using HTTPie Conclusions Why you should avoid JWT for Django Rest Framework authentication JWT (Json Web Token) is a very popular method to provide authentication in APIs. If you are developing a modern web application with Vue.js or React as the frontend and Django Rest Framework as the backend, there is an high probability that you are considering JWT as the best method to implement authentication. The reality is that JWT is just one method, and unfortunately not the simpler, nor the most reliable. JWT is not … -
Four Tips for Writing Better Go APIs
Go is a really powerful programming language that allows you to write concurrent code that is still easy to understand. But designing APIs can be hard, even for seasoned Go programmers. When designing APIs for libraries and applications in Go it's important to keep in mind the strengths of the language to make your APIs easier to use and avoid pitfalls like goroutine leaks. With that in mind, here are a few common issues I see often with Go APIs and some tips for how to make them better. ## Don't Take APIs Out of Context The context package is a very powerful package that takes some get[...] -
Zip Archive HTTP Response - Building SaaS with Python and Django #124
In this episode, we continued to build the PDF reporting feature. The focus on the stream was on building the zip archive file as the HTTP response. This will be the container for future PDF reports. I also started the setup for the weasyprint PDF package. -
Django News - Migrating WordPress to Wagtail - Jan 21st 2022
News WordPress to Wagtail CMS Migration Kit There are many reasons to migrate your WordPress site to Wagtail. Rest assured the migration doesn't need to be painful. wagtail.io Python 3.10.2, 3.9.10, and 3.11.0a4 are now available The releases you’re looking at were all cursed in some way. What a way to start 2022! python.org Wagtail Release 2.15.2 Bugfix with one security (CVE-2022-21683) update. github.com Events PyCascades 2022 Schedule PyCascades is remote on February 5-6, 2022. The schedule of talks is now available. pycascades.com Sponsored Link Stay secure with CodeStasis Keep your old Django install secure with our backported patches fixing security vulnerabilities and data loss bugs. Django 1.8 and up available now at www.codestasis.com. Get notified when 1.6 and 1.7 are released. CodeStasis is free for personal use and a paid subscription for businesses. codestasis.com Articles Why is Exposing the Docker Socket a Really Bad Idea? An exploration of why Django sockets should not be exposed in most cases and a real-world use case where the Docker socket needs to be mounted in your container. quarkslab.com Faster API development with django-dataclasses A description of features contained in the new django-dataclasses library and why it was created. medium.com Tutorials How to … -
Zip Archive HTTP Response - Building SaaS #124
In this episode, we continued to build the PDF reporting feature. The focus on the stream was on building the zip archive file as the HTTP response. This will be the container for future PDF reports. I also started the setup for the weasyprint PDF package. -
A Problem with Duplicated Mutable Constants
Here’s a small problem I’ve seen where several modules share versions of the same “constant” variable. It came up in the context of a Django project with multiple settings files, but it could happen in different contexts. Imagine you have two submodules defining API_CONFIG as a “constant” dictinoary. The development submodule should copy the value in base, but use a different value for the "rate_limit" key. You have example/base.py which looks like: API_CONFIG = { # ... "rate_limit": "10/m", # ... } …and example/development.py: from example.base import API_CONFIG API_CONFIG["rate_limit"] = "100/m" By importing from base, the development module doesn’t need to completely redefine API_CONFIG. Great - the redundant repetition is reduced. But can you see the flaw in this approach? The problem is that API_CONFIG is the same dict in both modules. The change in development “leaks” back to base: In [1]: from example import base In [2]: base.API_CONFIG["rate_limit"] Out[2]: '10/m' In [3]: from example import development In [4]: development.API_CONFIG["rate_limit"] Out[4]: '100/m' In [5]: base.API_CONFIG["rate_limit"] Out[5]: '100/m' Eek! This happens because Python variables are only names for underlying objects. Pointing another name to the same variable does not create a copy. If this is surprising, Ned Batchelder’s Python Names and … -
Django Best Practices: Template Structure
There are two main ways to organize your template structure in Django: the default app-level way and a custom project-level approach. ## Option 1: App Level By default the Django …