misc: defer null-character check in api to submodule initialization (#48114)

This commit is contained in:
Paul Marillonnet 2020-10-29 11:58:23 +01:00 committed by Thomas NOEL
parent 8d6b4653e3
commit 1cc2fdf70d
2 changed files with 5 additions and 3 deletions

View File

@ -21,7 +21,6 @@ default_app_config = 'authentic2.app.Authentic2Config'
if django.VERSION < (2,):
from . import validators
from django.forms import fields
import rest_framework.fields
# query-string and form parameters used to query database charfield must be checked for NULL characters
# https://code.djangoproject.com/ticket/30064
@ -34,4 +33,3 @@ if django.VERSION < (2,):
fields.CharField.__init__ = CharField_new_init__
fields.CharField.a2_workaround = True
rest_framework.fields.ProhibitNullCharactersValidator = validators.ProhibitNullCharactersValidator

View File

@ -66,7 +66,11 @@ from .models import Attribute, PasswordReset, Service
from .a2_rbac.utils import get_default_ou
# Retro-compatibility with Django 1.8
# Retro-compatibility with older Django versions
if django.VERSION < (2,):
import rest_framework.fields
from . import validators
rest_framework.fields.ProhibitNullCharactersValidator = validators.ProhibitNullCharactersValidator
if django.VERSION < (1, 11):
authentication.authenticate = utils.authenticate