Brad's Blog

Published: 2015-09-30

Django Admin Filters from ArrayFields

admin array arrayfield django filter postgresql

I've written before about the cool ArrayField support in Django, and this is another such post. In this one, we'll take a look and see how to turn your model's ArrayField values into filters in the admin. To start out, let's assume we have a model that contains a simple title (a CharField) and some keywords (an ArrayField). It might look something like this: from django.db import models class Item(models.Model): title = models.CharField ...


Published: 2015-04-25

Nice ArrayField widgets with choices and chosen.js

arrayfield django postgresql python

One of the really cool new features in Django 1.8 is the support for Postgres-specific fields. I'm very excited to be able to use things like PostgreSQL arrays or hstore without 3rd-party add-ons. Unfortnately, the default form inputs for ArrayFields are less than stellar. So, in this post I want to explore a few things: a Model who's ArrayField only accepts items from a set of predefined choices a ModelForm that makes use of chosen.js (which ...