rest_framework.compat

The compat module provides support for backwards compatibility with older versions of Django/Python, and compatibility wrappers around optional packages.

Module Contents

ProhibitNullCharactersValidator
mock
get_original_route(urlpattern)

Get the original route/regex that was typed in by the user into the path(), re_path() or url() directive. This is in contrast with get_regex_pattern below, which for RoutePattern returns the raw regex generated from the path().

get_regex_pattern(urlpattern)

Get the raw regex out of the urlpattern’s RegexPattern or RoutePattern. This is always a regular expression, unlike get_original_route above.

is_route_pattern(urlpattern)
make_url_resolver(regex, urlpatterns)
unicode_repr(instance)
unicode_to_repr(value)
unicode_http_header(value)
distinct(queryset, base)
postgres_fields
coreapi
coreschema
yaml
crispy_forms
requests
is_guardian_installed()

django-guardian is optional and only imported if in INSTALLED_APPS.

http_method_names
HEADERID_EXT_PATH = headerid
pygments_highlight(text, lang, style)
class CodeBlockPreprocessor

Bases:markdown.preprocessors.Preprocessor

pattern
formatter
run(self, lines)
path
SHORT_SEPARATORS = [',', ':']
class CustomValidatorMessage(*args, **kwargs)

Bases:object

We need to avoid evaluation of lazy translated message in django.core.validators.BaseValidator.__init__. https://github.com/django/django/blob/75ed5900321d170debef4ac452b8b3cf8a1c2384/django/core/validators.py#L297

Ref: https://github.com/encode/django-rest-framework/pull/5452

class MinValueValidator

Bases:rest_framework.compat.CustomValidatorMessage, django.core.validators.MinValueValidator

class MaxValueValidator

Bases:rest_framework.compat.CustomValidatorMessage, django.core.validators.MaxValueValidator

class MinLengthValidator

Bases:rest_framework.compat.CustomValidatorMessage, django.core.validators.MinLengthValidator

class MaxLengthValidator

Bases:rest_framework.compat.CustomValidatorMessage, django.core.validators.MaxLengthValidator

PY36