суббота, 15 декабря 2012 г.

Install PIL on Windows

I'm tired to remember how to do it every time when I start new project. So here is how we doing.

Activate virtualenv:
> \Users\MyUser\.virtualenvs\myvirtualenv\Scripts\activate.bat

Building PIL C libraries from sources under Windows is rather painful, so we will install precompiled binaries, which can be found here:
> easy_install https://pypi.python.org/packages/2.7/P/Pillow/Pillow-2.0.0-py2.7-win32.egg

пятница, 14 декабря 2012 г.

DateTimeField doesn't accept ISO 8601 formatted date string



You can find roots of this problem here in django sources and here in python bugs.

You can even find some solutions for this problem which suggests you to append extended patterns (with %z key) to DATETIME_INPUT_FORMATS, but they doesn't work in most cases.

So here is my workaround to solve this problem: just install python-dateutil package and add to your settings.py following lines:

# Patch datetime field parser
from dateutil import parser
from django.forms import fields
fields.DateTimeField.strptime = lambda o, v, f: parser.parse(v)