diff --git a/extra_views/generic.py b/extra_views/generic.py index 73287d4..6bcdea0 100644 --- a/extra_views/generic.py +++ b/extra_views/generic.py @@ -1,4 +1,10 @@ -from django.contrib.contenttypes.generic import generic_inlineformset_factory, BaseGenericInlineFormSet +import django + +if django.VERSION < (1, 8): + from django.contrib.contenttypes.generic import generic_inlineformset_factory, BaseGenericInlineFormSet +else: + from django.contrib.contenttypes.forms import generic_inlineformset_factory, BaseGenericInlineFormSet + from extra_views.formsets import BaseInlineFormSetMixin, InlineFormSetMixin, BaseInlineFormSetView, InlineFormSetView diff --git a/extra_views/tests/models.py b/extra_views/tests/models.py index 609ec6d..ce1cff2 100644 --- a/extra_views/tests/models.py +++ b/extra_views/tests/models.py @@ -3,9 +3,14 @@ from django.utils.timezone import now except ImportError: now = datetime.datetime.now +import django from django.db import models from django.contrib.contenttypes.models import ContentType -from django.contrib.contenttypes import generic + +if django.VERSION < (1, 8): + from django.contrib.contenttypes.generic import GenericForeignKey +else: + from django.contrib.contenttypes.fields import GenericForeignKey STATUS_CHOICES = ( (0, 'Placed'), @@ -38,7 +43,7 @@ class Tag(models.Model): name = models.CharField(max_length=255) content_type = models.ForeignKey(ContentType, null=True) object_id = models.PositiveIntegerField(null=True) - content_object = generic.GenericForeignKey('content_type', 'object_id') + content_object = GenericForeignKey('content_type', 'object_id') def __unicode__(self): return self.name diff --git a/extra_views/tests/tests.py b/extra_views/tests/tests.py index d4117b8..cd03fef 100644 --- a/extra_views/tests/tests.py +++ b/extra_views/tests/tests.py @@ -7,7 +7,11 @@ from django.core.exceptions import ImproperlyConfigured from django.forms import ValidationError from django.test import TransactionTestCase -from django.utils.unittest import expectedFailure + +if django.VERSION < (1, 8): + from django.utils.unittest import expectedFailure +else: + from unittest import expectedFailure from .models import Item, Order, Tag, Event