Posts tagged ‘django’ (Page 2)

(All tags.)

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:


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.


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.


How to convert a TestCase from setUp() to setUpTestData()

“Owl help you speed up your tests!”

Django’s TestCase class provides the setUpTestData() hook for creating your test data. It is faster than using the unittest setUp() hook because it creates the test data only once per test case, rather than per test.


Using Django Check Constraints to Prevent Self-Following

This puppy would follow you anywhere.

Another way to use Django’s CheckConstraint class to ensure your data is valid. Based on my answer to a question on the Django forum.


Improve your Django experience with IPython

Make your shell better

IPython is an improved Python shell for interactive use. It has many great features such as syntax highlighting, autocomplete, and powerful “magic commands”. I love it, use it on every project, and use the IPython prompt for examples on my blog.


Django’s release code words, up until 3.2

A true cornucopia of words

It’s now a long-running tradition that each Django release has an associated “code word”. This is used by the release manager in the announcement blog post to describe the list of features coming in the next version.


New Testing Features in Django 3.2

A veritable treasure trove of improvements.

Django 3.2 had its first alpha release a couple of weeks ago and the final release will be out in April. It contains a mezcla of new features, which you can check out in the release notes. This post focuses on the changes to testing, a few of which you can get on earlier Django versions with backport packages.


Using Django Check Constraints to Limit A Model to a Single Instance

A most singular unicorn.

Yet another use case for creating a database constraint with Django’s CheckConstraint class.


Using Django Check Constraints to Prevent the Storage of The Empty String

Go team dog!

Here’s another use case for creating a database constraint with Django’s CheckConstraint class.