Skip to main content
Nick Sergeant
March 25, 2013

Upgrading from Django 1.4 to Django 1.5

Recently I had the pleasure of upgrading from Django 1.4 to Django 1.5. They've introduced some awesome new stuff like beefier timezone support and a configurable User model. 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 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 olddirect_to_templategeneric 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 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. You should Gittip him.

Primarily,django-registrationhas 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 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 fromdjango-registrationwith custom forms:

  1. First off, make sure you're using the django-registration from Bitbucket, not pip. It should land on pip soon, but for now do this. When you install it, you must also have Django installed first. I have no idea why this is the case.
  2. Second, set up your custom registration_register URL.
  3. Create your custom registration form.
  4. Create your custom registration view and point it to the form.
  5. Make sure your custom registration view sub classes the RegistrationView from registration.backends.default.views.

django-haystack

This may or may not be 1.5-specific, but you need to make sure yourindex_querysetis accepting**kwargs, like this.

pyelasticsearch

This was fun. Both of thesepyelasticsearchrepos will fail in 1.5:

You need to specifically install version 0.3 frompip.

FLX Websites Logo