mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Identify code that needs to be pulled out of/removed from compat.py
This commit is contained in:
parent
018e43e908
commit
c950b7c43c
|
@ -78,6 +78,7 @@ def distinct(queryset, base):
|
||||||
return queryset.distinct()
|
return queryset.distinct()
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
# Obtaining manager instances and names from model options differs after 1.10.
|
# Obtaining manager instances and names from model options differs after 1.10.
|
||||||
def get_names_and_managers(options):
|
def get_names_and_managers(options):
|
||||||
if django.VERSION >= (1, 10):
|
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
|
# field.rel is deprecated from 1.9 onwards
|
||||||
def get_remote_field(field, **kwargs):
|
def get_remote_field(field, **kwargs):
|
||||||
if 'default' in kwargs:
|
if 'default' in kwargs:
|
||||||
|
@ -132,30 +134,35 @@ def _resolve_model(obj):
|
||||||
raise ValueError("{0} is not a Django model".format(obj))
|
raise ValueError("{0} is not a Django model".format(obj))
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
def is_authenticated(user):
|
def is_authenticated(user):
|
||||||
if django.VERSION < (1, 10):
|
if django.VERSION < (1, 10):
|
||||||
return user.is_authenticated()
|
return user.is_authenticated()
|
||||||
return user.is_authenticated
|
return user.is_authenticated
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
def is_anonymous(user):
|
def is_anonymous(user):
|
||||||
if django.VERSION < (1, 10):
|
if django.VERSION < (1, 10):
|
||||||
return user.is_anonymous()
|
return user.is_anonymous()
|
||||||
return user.is_anonymous
|
return user.is_anonymous
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
def get_related_model(field):
|
def get_related_model(field):
|
||||||
if django.VERSION < (1, 9):
|
if django.VERSION < (1, 9):
|
||||||
return _resolve_model(field.rel.to)
|
return _resolve_model(field.rel.to)
|
||||||
return field.remote_field.model
|
return field.remote_field.model
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
def value_from_object(field, obj):
|
def value_from_object(field, obj):
|
||||||
if django.VERSION < (1, 9):
|
if django.VERSION < (1, 9):
|
||||||
return field._get_val_from_obj(obj)
|
return field._get_val_from_obj(obj)
|
||||||
return field.value_from_object(obj)
|
return field.value_from_object(obj)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
# contrib.postgres only supported from 1.8 onwards.
|
# contrib.postgres only supported from 1.8 onwards.
|
||||||
try:
|
try:
|
||||||
from django.contrib.postgres import fields as postgres_fields
|
from django.contrib.postgres import fields as postgres_fields
|
||||||
|
@ -163,6 +170,7 @@ except ImportError:
|
||||||
postgres_fields = None
|
postgres_fields = None
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
# JSONField is only supported from 1.9 onwards
|
# JSONField is only supported from 1.9 onwards
|
||||||
try:
|
try:
|
||||||
from django.contrib.postgres.fields import JSONField
|
from django.contrib.postgres.fields import JSONField
|
||||||
|
@ -292,6 +300,7 @@ else:
|
||||||
LONG_SEPARATORS = (b', ', b': ')
|
LONG_SEPARATORS = (b', ', b': ')
|
||||||
INDENT_SEPARATORS = (b',', b': ')
|
INDENT_SEPARATORS = (b',', b': ')
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
try:
|
try:
|
||||||
# DecimalValidator is unavailable in Django < 1.9
|
# DecimalValidator is unavailable in Django < 1.9
|
||||||
from django.core.validators import DecimalValidator
|
from django.core.validators import DecimalValidator
|
||||||
|
@ -338,6 +347,7 @@ def set_rollback():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
def template_render(template, context=None, request=None):
|
def template_render(template, context=None, request=None):
|
||||||
"""
|
"""
|
||||||
Passing Context or RequestContext to Template.render is deprecated in 1.9+,
|
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)
|
return template.render(context, request=request)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
def set_many(instance, field, value):
|
def set_many(instance, field, value):
|
||||||
if django.VERSION < (1, 10):
|
if django.VERSION < (1, 10):
|
||||||
setattr(instance, field, value)
|
setattr(instance, field, value)
|
||||||
|
@ -368,6 +379,7 @@ def set_many(instance, field, value):
|
||||||
field.set(value)
|
field.set(value)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
def include(module, namespace=None, app_name=None):
|
def include(module, namespace=None, app_name=None):
|
||||||
from django.conf.urls import include
|
from django.conf.urls import include
|
||||||
if django.VERSION < (1,9):
|
if django.VERSION < (1,9):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user