Posts tagged ‘django’


Django 3.2 Update for “Speed Up Your Django Tests” Released

Doot-doot-de-doot!

I released my book “Speed Up Your Django Tests” over a year ago, in May 2020. Since then, we’ve seen two major Django releases, including a whole bunch of test-related changes, some of which I worked on as part of the book.

Read more...

How to use Python’s HTTPStatus with Django

Snaily McSnailface says “use HTTPStatus”!

A “magic number” is the anti-pattern of using a number directly rather than storing it in a descriptive variable name. In web code HTTP status codes are often used as magic numbers, perhaps because web developers memorize common codes such as 200 and 404. In Python, we can avoid such magic with descriptive references from the standard library’s http.HTTPStatus enum.

Read more...

DjangoCon Europe 2021 Sale of “Speed Up Your Django Tests”

Artist’s impression of all the money you can save!

I released my book Speed Up your Django Tests (SUYDT) just over a year ago, on the 18th May. It’s had a great reception, with 379 customers so far, many writing in to say how it has improved their test suites’ performance and readability.

Read more...

How to Build a Webhook Receiver in Django

Well, I’m hooked.

A common way to receive data in a web application is with a webhook. The external system pushes data to yours with an HTTP request.

Read more...

Using Django Check Constraints to Limit the Range of an IntegerField

Measure twice, cut out bad data.

Another way to use database constraints via Django’s CheckConstraint class.

Read more...

3 uses for functools.partial in Django

I am rather partial to a plant-scroll.

Python’s functools.partial is a great tool that I feel is underused.

Read more...

Disabling FLoC, Google’s new advertising technology

Birds of a similar browsing history FLoC together

Google has started rolling out FLoC, currently to 0.5% of Chrome users, and some sites are already disabling it. In this post we’ll cover what FLoC is, who’s disabling it, why, and how to do so on a Django site.

Read more...

How to set the new COEP, COOP, and CORP security headers in Django

“Where’s my coop?”

Here are three new security headers on the block:

Read more...

Introducing the heroicons Python Package

Only iconography can tell us what is going on here.

heroicons is a free SVG icon set for your websites, from the creators of tailwindcss. SVG icons are great - they’re small, they sit inline in your HTML, and you can scaled and colour them with plain HTML and CSS. And heroicons is a great icon set - minimal, clear, and consistent.

Read more...

django-feature-policy is now django-permissions-policy

This sheep doesn’t need permission to walk how it likes.

I created django-feature-policy in 2018 allow Django projects to control the draft security header Feature-Policy. Feature-Policy allows your site to restrict which origins can use some sensitive browser features, such as the the payments API or access to the webcam. This is valuable if you’re using any third party JavaScript. Whether such JavaScript comes from npm or an external script tag, you can protect against it doing some bad things with your users.

Read more...

All tags: