Django 1.6 urls.defaults compatibility work-around

ImportError: No module named defaults

Getting this error on your under-maintained third party django apps? First go bug the maintainer with a pull request removing the defaults in

from django.conf.urls.defaults import *
# should be
from django.conf.urls import *

After that you can work around the issue if you don’t feel like forking the app. Just copy their urls.py file into your application then import that urls file instead.

For example let’s say you want to use django-ckeditor. Copy their urls.py file into your project. Maybe call it ckeditor_urls.py and remove “defaults”

Now in your project’s url.py change:

(r'^ckeditor/', include('ckeditor.urls')),
# change to
(r'^ckeditor/', include('mystuff.ckeditor_urls')),

Once the 3rd party app fixes their app you can just revert this change.

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA Image

*