Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
added get_remote_field compat function
  • Loading branch information
auvipy committed Apr 20, 2016
commit 3e8f1c9b3a80a85308a8f41fe76941fac4168eb5
15 changes: 15 additions & 0 deletions rest_framework/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,18 @@ def template_render(template, context=None, request=None):
# backends template, e.g. django.template.backends.django.Template
else:
return template.render(context, request=request)

def get_remote_field(field):
"""
Django 1.9 removed usage of Rel objects, see
https://github.com/django/django/pull/4241

:param field: Field
:return: remote field
"""
from django.db.models import fields

if django.VERSION < (1, 9):
return field.rel
else:
return field.remote_field