@@ -86,18 +86,6 @@ def distinct(queryset, base):
8686 crispy_forms = None
8787
8888
89- if django .VERSION >= (1 , 6 ):
90- def clean_manytomany_helptext (text ):
91- return text
92- else :
93- # Up to version 1.5 many to many fields automatically suffix
94- # the `help_text` attribute with hardcoded text.
95- def clean_manytomany_helptext (text ):
96- if text .endswith (' Hold down "Control", or "Command" on a Mac, to select more than one.' ):
97- text = text [:- 69 ]
98- return text
99-
100-
10189# Django-guardian is optional. Import only if guardian is in INSTALLED_APPS
10290# Fixes (#1712). We keep the try/except for the test suite.
10391guardian = None
@@ -109,41 +97,6 @@ def clean_manytomany_helptext(text):
10997 pass
11098
11199
112- # MinValueValidator, MaxValueValidator et al. only accept `message` in 1.8+
113- if django .VERSION >= (1 , 8 ):
114- from django .core .validators import MinValueValidator , MaxValueValidator
115- from django .core .validators import MinLengthValidator , MaxLengthValidator
116- else :
117- from django .core .validators import MinValueValidator as DjangoMinValueValidator
118- from django .core .validators import MaxValueValidator as DjangoMaxValueValidator
119- from django .core .validators import MinLengthValidator as DjangoMinLengthValidator
120- from django .core .validators import MaxLengthValidator as DjangoMaxLengthValidator
121-
122-
123- class MinValueValidator (DjangoMinValueValidator ):
124- def __init__ (self , * args , ** kwargs ):
125- self .message = kwargs .pop ('message' , self .message )
126- super (MinValueValidator , self ).__init__ (* args , ** kwargs )
127-
128-
129- class MaxValueValidator (DjangoMaxValueValidator ):
130- def __init__ (self , * args , ** kwargs ):
131- self .message = kwargs .pop ('message' , self .message )
132- super (MaxValueValidator , self ).__init__ (* args , ** kwargs )
133-
134-
135- class MinLengthValidator (DjangoMinLengthValidator ):
136- def __init__ (self , * args , ** kwargs ):
137- self .message = kwargs .pop ('message' , self .message )
138- super (MinLengthValidator , self ).__init__ (* args , ** kwargs )
139-
140-
141- class MaxLengthValidator (DjangoMaxLengthValidator ):
142- def __init__ (self , * args , ** kwargs ):
143- self .message = kwargs .pop ('message' , self .message )
144- super (MaxLengthValidator , self ).__init__ (* args , ** kwargs )
145-
146-
147100# PATCH method is not implemented by Django
148101if 'patch' not in View .http_method_names :
149102 View .http_method_names = View .http_method_names + ['patch' ]
@@ -188,13 +141,6 @@ def apply_markdown(text):
188141 LONG_SEPARATORS = (b', ' , b': ' )
189142 INDENT_SEPARATORS = (b',' , b': ' )
190143
191- if django .VERSION >= (1 , 8 ):
192- from django .db .models import DurationField
193- from django .utils .dateparse import parse_duration
194- from django .utils .duration import duration_string
195- else :
196- DurationField = duration_string = parse_duration = None
197-
198144try :
199145 # DecimalValidator is unavailable in Django < 1.9
200146 from django .core .validators import DecimalValidator
@@ -223,14 +169,14 @@ def template_render(template, context=None, request=None):
223169 """
224170 Passing Context or RequestContext to Template.render is deprecated in 1.9+,
225171 see https://github.com/django/django/pull/3883 and
226- https://github.com/django/django/blob/1.9rc1 /django/template/backends/django.py#L82-L84
172+ https://github.com/django/django/blob/1.9 /django/template/backends/django.py#L82-L84
227173
228174 :param template: Template instance
229175 :param context: dict
230176 :param request: Request instance
231177 :return: rendered template as SafeText instance
232178 """
233- if django . VERSION < ( 1 , 8 ) or isinstance (template , Template ):
179+ if isinstance (template , Template ):
234180 if request :
235181 context = RequestContext (request , context )
236182 else :
@@ -239,32 +185,3 @@ def template_render(template, context=None, request=None):
239185 # backends template, e.g. django.template.backends.django.Template
240186 else :
241187 return template .render (context , request = request )
242-
243-
244- def get_all_related_objects (opts ):
245- """
246- Django 1.8 changed meta api, see
247- https://docs.djangoproject.com/en/1.8/ref/models/meta/#migrating-old-meta-api
248- https://code.djangoproject.com/ticket/12663
249- https://github.com/django/django/pull/3848
250-
251- :param opts: Options instance
252- :return: list of relations except many-to-many ones
253- """
254- if django .VERSION < (1 , 8 ):
255- return opts .get_all_related_objects ()
256- else :
257- return [r for r in opts .related_objects if not r .field .many_to_many ]
258-
259-
260- def get_all_related_many_to_many_objects (opts ):
261- """
262- Django 1.8 changed meta api, see docstr in compat.get_all_related_objects()
263-
264- :param opts: Options instance
265- :return: list of many-to-many relations
266- """
267- if django .VERSION < (1 , 8 ):
268- return opts .get_all_related_many_to_many_objects ()
269- else :
270- return [r for r in opts .related_objects if r .field .many_to_many ]
0 commit comments