mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-10 08:30:51 +03:00
Compat for GenericForeignKey, GenericRelation
This commit is contained in:
parent
4f27697467
commit
e70da5ac6b
|
@ -90,6 +90,16 @@ except ImportError:
|
||||||
from django.db.models import get_model
|
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
|
# django-filter is optional
|
||||||
try:
|
try:
|
||||||
import django_filters
|
import django_filters
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.contrib.contenttypes.fields import (
|
|
||||||
GenericForeignKey, GenericRelation
|
|
||||||
)
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
from rest_framework.compat import GenericForeignKey, GenericRelation
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
|
|
Loading…
Reference in New Issue
Block a user