Upgrading from Django 1.4 to Django 1.5
Recently I had the pleasure of upgrading from Django 1.4 to Django 1.5 (opens in new tab). They've introduced some awesome new stuff like beefier timezone support (opens in new tab) and a configurable User model (opens in new tab). However, there are some backwards-incompatible things you'll need to tend to.
Django settings
I ran into an issue with some app complaining about not being able to work with naive timezones. You'll need to add this to your settings.py:
USE_TZ = True
Tag changes
The URL tag (opens in new tab) has changed to take a path to a view function as a string. Previously this wasn't stringified.
{% url whatever args %} -> {% url 'whatever' args %}
direct_to_template
The old direct_to_template generic view has been changed to a more traditional class. Here's the new structure:
from django.views.generic import TemplateView
...
url(r'^500/$', TemplateView.as_view(template_name='500.html')),
django-registration
The quite-popular django-registration (opens in new tab) app took some time to get proper 1.5 support, but the awesome Mr. Bennett was able to get support rolling during a PyCon sprint (opens in new tab). You should Gittip him (opens in new tab).
Primarily, django-registration has been rewritten to use class-based views. If you had a custom form you were passing to your registration app, you'll need to do some things.
On Snipt (opens in new tab) I use a custom registration form that further restricts characters in usernames, as well as forces uniqueness of email site-wide. Here's what you need to do to get 1.5 support from django-registration with custom forms:
- First off, make sure you're using the
django-registrationfrom Bitbucket, not pip. It should land on pip soon, but for now do this (opens in new tab). When you install it, you must also have Django installed first. I have no idea why this is the case. - Second, set up your custom registration_register URL (opens in new tab).
- Create your custom registration form (opens in new tab).
- Create your custom registration view (opens in new tab) and point it to the form.
- Make sure your custom registration view sub classes the
RegistrationViewfromregistration.backends.default.views.
django-haystack
This may or may not be 1.5-specific, but you need to make sure your index_queryset is accepting **kwargs, like this (opens in new tab).
pyelasticsearch
This was fun. Both of these pyelasticsearch repos will fail in 1.5:
- https://github.com/toastdriven/pyelasticsearch (opens in new tab)
- https://github.com/rhec/pyelasticsearch (opens in new tab)
You need to specifically install version 0.3 (opens in new tab) from pip.
