Django's CommaSeparatedIntegerField
It doesn't do what you think it does, but it can still be useful.
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 . . .
Mocking dates with Django
It's not as simple as it at first appears - some tips from the frontline.
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 . . .
Django middleware, sessions and users
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 . . .
Custom filters for Django objects
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, . . .
Deploying Django apps to Heroku (#3)
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, . . .
Packaging Django apps
Packaging Django-aware libraries for distribution
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 . . .