Django's CommaSeparatedIntegerField

It doesn't do what you think it does, but it can still be useful.

June 04, 2014

I've you ever need to store lists of IDs in a field in Django, you've probably
come across the CommaSeparatedIntegerField. It sounds ideal - you can save
lists to and from the database. Brilliant.

Except that that's not how it works. The CommaSeparatedIntegerField is in
fact nothing more than a CharField with a regex validator ( . . .

Read More

Mocking dates with Django

It's not as simple as it at first appears - some tips from the frontline.

December 01, 2013

A lot of what we do at YJ is date-dependent, and amongst our unit tests we have (as I now know) 500+ tests that rely in some sense on the value of python's datetime.date.today() function.

Since launching YJ we have been running on Django 1.4, and mocking out datetime.date using the technique outlined in this article:

from datetime import . . .

Read More

Django middleware, sessions and users

September 06, 2013

A brief walkthrough of the Django session and authentication middleware.

tl;dr If you already know how Django sessions and auth work, read no further - you won't learn anything new.

Coming from a .NET 'enterprise' background, one of the things that confused me at first about Django was the phrase 'middleware'. In my old . . .

Read More

Custom filters for Django objects

July 16, 2013

Using mixins to add fluid filters to Django model managers.

There are plenty of samples on the web showing how to create custom Django
QuerySet and Manager classes to create fluid manager interfaces; here's
another one.

We have a lot of shared fields across models, that we filter on in similar
ways, irrespective of the model. A good . . .

Read More

Deploying Django apps to Heroku (#3)

July 11, 2013

In the third (probably not final) post on our deployment process, our Fabric
script has become intelligent enough to manage deployment options on our
behalf.

First a quick recap. As I've posted previously, YunoJuno is a Django app,
hosted on Heroku. We use Fabric to manage deployments, which, as is the
Heroku way, start with a git push, . . .

Read More

Packaging Django apps

Packaging Django-aware libraries for distribution

March 07, 2013

Packaging apps so that they can be tested within a django context, but without having to add them to an existing django project is pretty easy to to, but takes a bit more work than a standalone application.

We recently pushed our django-errordite and python-errordite apps to PyPI, and as part of that process I was keen to ensure that we . . .

Read More

Archive
  Subscribe by Email and Never Miss a Post