Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #17275 -- Moved some imports back from module level to class le…

…vel to prevent the test suite from raising warnings.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17164 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit be8938f0d83911f33f9e439fea925a7f32ab5c96 1 parent 0d0f874
Aymeric Augustin aaugustin authored
5 django/contrib/localflavor/ca/forms.py
View
@@ -6,7 +6,6 @@
import re
-from django.contrib.localflavor.ca.ca_provinces import PROVINCE_CHOICES, PROVINCES_NORMALIZED
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, CharField, Select
@@ -79,6 +78,8 @@ def clean(self, value):
except AttributeError:
pass
else:
+ # Load data in memory only when it is required, see also #17275
+ from django.contrib.localflavor.ca.ca_provinces import PROVINCES_NORMALIZED
try:
return PROVINCES_NORMALIZED[value.strip().lower()].decode('ascii')
except KeyError:
@@ -91,6 +92,8 @@ class CAProvinceSelect(Select):
territories as its choices.
"""
def __init__(self, attrs=None):
+ # Load data in memory only when it is required, see also #17275
+ from django.contrib.localflavor.ca.ca_provinces import PROVINCE_CHOICES
super(CAProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
class CASocialInsuranceNumberField(Field):
7 django/contrib/localflavor/id/forms.py
View
@@ -8,7 +8,6 @@
import time
from django.core.validators import EMPTY_VALUES
-from django.contrib.localflavor.id.id_choices import PROVINCE_CHOICES, LICENSE_PLATE_PREFIX_CHOICES
from django.forms import ValidationError
from django.forms.fields import Field, Select
from django.utils.translation import ugettext_lazy as _
@@ -58,6 +57,8 @@ class IDProvinceSelect(Select):
"""
def __init__(self, attrs=None):
+ # Load data in memory only when it is required, see also #17275
+ from django.contrib.localflavor.id.id_choices import PROVINCE_CHOICES
super(IDProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
@@ -93,6 +94,8 @@ class IDLicensePlatePrefixSelect(Select):
"""
def __init__(self, attrs=None):
+ # Load data in memory only when it is required, see also #17275
+ from django.contrib.localflavor.id.id_choices import LICENSE_PLATE_PREFIX_CHOICES
super(IDLicensePlatePrefixSelect, self).__init__(attrs,
choices=LICENSE_PLATE_PREFIX_CHOICES)
@@ -110,6 +113,8 @@ class IDLicensePlateField(Field):
}
def clean(self, value):
+ # Load data in memory only when it is required, see also #17275
+ from django.contrib.localflavor.id.id_choices import LICENSE_PLATE_PREFIX_CHOICES
super(IDLicensePlateField, self).clean(value)
if value in EMPTY_VALUES:
return u''
Please sign in to comment.
Something went wrong with that request. Please try again.