Skip to content

Commit

Permalink
Allow for using django-cbv in Django 1.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Oordt committed May 11, 2011
1 parent 4ce5a9e commit 4081fe8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions categories/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import django
from django.shortcuts import get_object_or_404
from django.template import RequestContext
from django.http import HttpResponse, Http404
Expand Down Expand Up @@ -46,10 +47,17 @@ def get_category_for_path(path, queryset=Category.objects.all()):
level = len(path_items)-1)
return queryset.get()

try:
import cbv
HAS_CBV = True
except ImportError:
HAS_CBV = False

import django
if django.VERSION[0] >= 1 and django.VERSION[1] >= 3:
from django.views.generic import DetailView, ListView
if ((django.VERSION[0] >= 1 and django.VERSION[1] >= 3) or HAS_CBV):
if HAS_CBV:
from cbv import DetailView, ListView
else:
from django.views.generic import DetailView, ListView

class CategoryDetailView(DetailView):

Expand Down

0 comments on commit 4081fe8

Please sign in to comment.