Fixing a few minor Django 1.5 incompatibilities

This commit is contained in:
Corey Oordt 2013-03-20 06:52:09 -05:00
parent 8ce56e8190
commit c6f122d724
3 changed files with 17 additions and 7 deletions

View file

@ -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'
),
)

View file

@ -123,7 +123,7 @@ CATEGORIES_SETTINGS = {
},
}
if django.VERSION[1] == 4:
if django.VERSION[1] >= 4:
from settings14 import *
if django.VERSION[1] == 3:
from settings13 import *

View file

@ -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
@ -13,7 +13,7 @@ urlpatterns = patterns('',
# 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')),
@ -32,4 +32,4 @@ urlpatterns = patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': os.path.join(ROOT_PATH, 'example', 'static')}),
)
)