Compat for GenericForeignKey, GenericRelation

This commit is contained in:
Tom Christie 2015-08-28 10:03:08 +01:00
parent 4f27697467
commit e70da5ac6b
2 changed files with 11 additions and 3 deletions

View File

@ -90,6 +90,16 @@ except ImportError:
from django.db.models import get_model
# Import path changes from 1.7 onwards.
try:
from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation
)
except ImportError:
from django.contrib.contenttypes.generic import (
GenericForeignKey, GenericRelation
)
# django-filter is optional
try:
import django_filters

View File

@ -1,14 +1,12 @@
from __future__ import unicode_literals
from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.test import TestCase
from django.utils.encoding import python_2_unicode_compatible
from rest_framework import serializers
from rest_framework.compat import GenericForeignKey, GenericRelation
@python_2_unicode_compatible