From c950b7c43cc57493ead1ecabbe7ccb5d1db4848a Mon Sep 17 00:00:00 2001 From: Levi Payne Date: Sun, 1 Oct 2017 21:06:11 -0400 Subject: [PATCH] Identify code that needs to be pulled out of/removed from compat.py --- rest_framework/compat.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index e0f718ced..614745a66 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -78,6 +78,7 @@ def distinct(queryset, base): return queryset.distinct() +# TODO: Remove # Obtaining manager instances and names from model options differs after 1.10. def get_names_and_managers(options): if django.VERSION >= (1, 10): @@ -96,6 +97,7 @@ def get_names_and_managers(options): ] +# TODO: Remove # field.rel is deprecated from 1.9 onwards def get_remote_field(field, **kwargs): if 'default' in kwargs: @@ -132,30 +134,35 @@ def _resolve_model(obj): raise ValueError("{0} is not a Django model".format(obj)) +# TODO: Remove def is_authenticated(user): if django.VERSION < (1, 10): return user.is_authenticated() return user.is_authenticated +# TODO: Remove def is_anonymous(user): if django.VERSION < (1, 10): return user.is_anonymous() return user.is_anonymous +# TODO: Remove def get_related_model(field): if django.VERSION < (1, 9): return _resolve_model(field.rel.to) return field.remote_field.model +# TODO: Remove def value_from_object(field, obj): if django.VERSION < (1, 9): return field._get_val_from_obj(obj) return field.value_from_object(obj) +# TODO: Remove # contrib.postgres only supported from 1.8 onwards. try: from django.contrib.postgres import fields as postgres_fields @@ -163,6 +170,7 @@ except ImportError: postgres_fields = None +# TODO: Remove # JSONField is only supported from 1.9 onwards try: from django.contrib.postgres.fields import JSONField @@ -292,6 +300,7 @@ else: LONG_SEPARATORS = (b', ', b': ') INDENT_SEPARATORS = (b',', b': ') +# TODO: Remove try: # DecimalValidator is unavailable in Django < 1.9 from django.core.validators import DecimalValidator @@ -338,6 +347,7 @@ def set_rollback(): pass +# TODO: Remove def template_render(template, context=None, request=None): """ Passing Context or RequestContext to Template.render is deprecated in 1.9+, @@ -360,6 +370,7 @@ def template_render(template, context=None, request=None): return template.render(context, request=request) +# TODO: Remove def set_many(instance, field, value): if django.VERSION < (1, 10): setattr(instance, field, value) @@ -368,6 +379,7 @@ def set_many(instance, field, value): field.set(value) +# TODO: Remove def include(module, namespace=None, app_name=None): from django.conf.urls import include if django.VERSION < (1,9):