Skip to content

Commit

Permalink
Improved Django 1.8 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign committed Apr 17, 2015
1 parent 43acf5a commit 14f45b4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions etc/templatetags/model_field.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from django import template, VERSION as DJANGO_VERSION
from django.conf import settings
from django.core.paginator import Page
from django.core.exceptions import FieldDoesNotExist
from django.db.models.query import QuerySet


django18plus = DJANGO_VERSION >= (1, 8)

if django18plus:
from django.core.exceptions import FieldDoesNotExist
else:
FieldDoesNotExist = KeyError

register = template.Library()


Expand Down Expand Up @@ -127,7 +132,7 @@ def return_contents(contents):

contents = getattr(model_field, self.attr_name)

except (KeyError, FieldDoesNotExist):
except FieldDoesNotExist:
contents = ''
if settings.DEBUG:
raise template.TemplateSyntaxError(
Expand Down

0 comments on commit 14f45b4

Please sign in to comment.