Skip to content

Commit

Permalink
Fixing a few minor Django 1.5 incompatibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Mar 20, 2013
1 parent 8ce56e8 commit c6f122d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
16 changes: 13 additions & 3 deletions categories/urls.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
from django.conf.urls.defaults import *
from django.conf.urls import patterns, url
from .models import Category

try:
from django.views.generic import DetailView, ListView
except ImportError:
try:
from cbv import DetailView, ListView
except ImportError:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("For older versions of Django, you need django-cbv.")


categorytree_dict = {
'queryset': Category.objects.filter(level=0)
}

urlpatterns = patterns('django.views.generic.list_detail',
urlpatterns = patterns('',
url(
r'^$', 'object_list', categorytree_dict, name='categories_tree_list'
r'^$', ListView.as_view(**categorytree_dict), name='categories_tree_list'
),
)

Expand Down
2 changes: 1 addition & 1 deletion example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
},
}

if django.VERSION[1] == 4:
if django.VERSION[1] >= 4:
from settings14 import *
if django.VERSION[1] == 3:
from settings13 import *
6 changes: 3 additions & 3 deletions example/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import patterns, include

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
Expand All @@ -13,7 +13,7 @@
# Example:
# (r'^sample/', include('sample.foo.urls')),

# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

Expand All @@ -32,4 +32,4 @@
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': os.path.join(ROOT_PATH, 'example', 'static')}),

)
)

0 comments on commit c6f122d

Please sign in to comment.