django-planet

What's new in Django community blogs?

Django: Sanitize incoming HTML fragments with nh3

Dec. 13, 2023 » Adam Johnson » [Archived Version]

A fairly common situation in a Django project is where you need to store and serve arbitrary HTML fragments. These often come from forms with rich text editors (using HTML’s contenteditable). It’s insecure to trust user-generated HTML fragments since they can contain naughty content like: <script src=https …

Read More

Raise the right exceptions

Dec. 12, 2023 » James Bennett » [Archived Version]

This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction. Let’s have an argument Suppose you write a function like this: def divide(dividend, divisor): """ Divide ``dividend`` by ``divisor`` and return the result. """ return dividend … Read full entry

Read More

Django Quiz 2023

Dec. 11, 2023 » Adam Johnson » [Archived Version]

This evening I held a quiz at the December London Django Meetup Group. The quiz is a regular tradition: this was the fifth quiz that I’ve presented, and the sixth overall. Here it is so you can try it at home - answers are at the bottom. Dates refer to …

Read More

PyCharm 2023.3: Feature Spotlight for Django Developers

Dec. 11, 2023 » The PyCharm Blog » [Archived Version]

PyCharm 2023.3 introduces a plethora of features for Django development: Django Structure tool window, Live preview for Django templates, enhancements in code assistance for the Django REST framework, and more! This release is poised to enhance the productivity of developers working with Django. Let’s delve into these functionalities. Try PyCharm for Django Django Structure Tool […]

Read More

Django: Defer a model field by default

Dec. 11, 2023 » Adam Johnson » [Archived Version]

Some models have one or a few large fields that dominate their per-instance size. For example, take a minimal blog post model: from django.db import models class Post(models.Model): blog = models.ForeignKey("Blog", on_delete=models.CASCADE) title = models.TextField() body = models.TextField() body is typically many times larger …

Read More

Tailwind CSS on Python and Heroku - Building SaaS

Dec. 11, 2023 » Django on Matt Layman » [Archived Version]

Tailwind CSS is a fantastic tool for making CSS easy to use on your webapps. On the video, I added Tailwind CSS to my Django app and showed how to use it and deploy it to Heroku (which required some extra configuration for JavaScript support).

Read More

Tailwind CSS on Python and Heroku - Building SaaS

Dec. 11, 2023 » Django on Matt Layman » [Archived Version]

Tailwind CSS is a fantastic tool for making CSS easy to use on your webapps. On the video, I added Tailwind CSS to my Django app and showed how to use it and deploy it to Heroku (which required some extra configuration for JavaScript support).

Read More

Database generated columns⁽³⁾: GeoDjango & PostGIS

Dec. 10, 2023 » Paolo Melchiorre » [Archived Version]

An introduction to database generated columns, using PostgGIS, GeoDjango and the new GeneratedField added in Django 5.0.

Read More

Test your documentation

Dec. 10, 2023 » James Bennett » [Archived Version]

This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction. Consider a docstring Suppose you’re writing a Python function and, as you’re supposed to do, you give it a docstring, and you even provide some examples of how the function is supposed … Read full entry

Read More

The longest year

Dec. 10, 2023 » Carlton's latest posts. » [Archived Version]

2023 in review. For the second year in a row 2023 ends with the dominant theme in life having been family ill-health. I feel like 2023 actually began in Oct 2022, when, as I was travelling back from DjangoCon US, my daughter had an accident and was hospitalized. Since then it’s been all go. My son spent most of the year being diagnosed and (kind-of) treated for a mysterious post-Covid illness that we’re still not sure exactly what to make of. He’s doing better, much better. But it’s been the…

Read More