Removed unnecessary arguments in .get method calls
This commit is contained in:
parent
f61c4f490d
commit
4157c502a5
|
@ -85,7 +85,7 @@ class SimpleListFilter(ListFilter):
|
||||||
query string for this filter, if any. If the value wasn't provided then
|
query string for this filter, if any. If the value wasn't provided then
|
||||||
returns None.
|
returns None.
|
||||||
"""
|
"""
|
||||||
return self.used_parameters.get(self.parameter_name, None)
|
return self.used_parameters.get(self.parameter_name)
|
||||||
|
|
||||||
def lookups(self, request, model_admin):
|
def lookups(self, request, model_admin):
|
||||||
"""
|
"""
|
||||||
|
@ -220,8 +220,8 @@ class BooleanFieldListFilter(FieldListFilter):
|
||||||
def __init__(self, field, request, params, model, model_admin, field_path):
|
def __init__(self, field, request, params, model, model_admin, field_path):
|
||||||
self.lookup_kwarg = '%s__exact' % field_path
|
self.lookup_kwarg = '%s__exact' % field_path
|
||||||
self.lookup_kwarg2 = '%s__isnull' % field_path
|
self.lookup_kwarg2 = '%s__isnull' % field_path
|
||||||
self.lookup_val = request.GET.get(self.lookup_kwarg, None)
|
self.lookup_val = request.GET.get(self.lookup_kwarg)
|
||||||
self.lookup_val2 = request.GET.get(self.lookup_kwarg2, None)
|
self.lookup_val2 = request.GET.get(self.lookup_kwarg2)
|
||||||
super(BooleanFieldListFilter, self).__init__(field,
|
super(BooleanFieldListFilter, self).__init__(field,
|
||||||
request, params, model, model_admin, field_path)
|
request, params, model, model_admin, field_path)
|
||||||
|
|
||||||
|
@ -350,9 +350,8 @@ class AllValuesFieldListFilter(FieldListFilter):
|
||||||
def __init__(self, field, request, params, model, model_admin, field_path):
|
def __init__(self, field, request, params, model, model_admin, field_path):
|
||||||
self.lookup_kwarg = field_path
|
self.lookup_kwarg = field_path
|
||||||
self.lookup_kwarg_isnull = '%s__isnull' % field_path
|
self.lookup_kwarg_isnull = '%s__isnull' % field_path
|
||||||
self.lookup_val = request.GET.get(self.lookup_kwarg, None)
|
self.lookup_val = request.GET.get(self.lookup_kwarg)
|
||||||
self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull,
|
self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull)
|
||||||
None)
|
|
||||||
parent_model, reverse_path = reverse_field_path(model, field_path)
|
parent_model, reverse_path = reverse_field_path(model, field_path)
|
||||||
# Obey parent ModelAdmin queryset when deciding which options to show
|
# Obey parent ModelAdmin queryset when deciding which options to show
|
||||||
if model == parent_model:
|
if model == parent_model:
|
||||||
|
|
|
@ -200,7 +200,7 @@ class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)):
|
||||||
ordering. Otherwise don't specify the queryset, let the field decide
|
ordering. Otherwise don't specify the queryset, let the field decide
|
||||||
(returns None in that case).
|
(returns None in that case).
|
||||||
"""
|
"""
|
||||||
related_admin = self.admin_site._registry.get(db_field.remote_field.model, None)
|
related_admin = self.admin_site._registry.get(db_field.remote_field.model)
|
||||||
if related_admin is not None:
|
if related_admin is not None:
|
||||||
ordering = related_admin.get_ordering(request)
|
ordering = related_admin.get_ordering(request)
|
||||||
if ordering is not None and ordering != ():
|
if ordering is not None and ordering != ():
|
||||||
|
|
|
@ -106,7 +106,7 @@ class UserChangeForm(forms.ModelForm):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(UserChangeForm, self).__init__(*args, **kwargs)
|
super(UserChangeForm, self).__init__(*args, **kwargs)
|
||||||
f = self.fields.get('user_permissions', None)
|
f = self.fields.get('user_permissions')
|
||||||
if f is not None:
|
if f is not None:
|
||||||
f.queryset = f.queryset.select_related('content_type')
|
f.queryset = f.queryset.select_related('content_type')
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Command(BaseCommand):
|
||||||
return super(Command, self).execute(*args, **options)
|
return super(Command, self).execute(*args, **options)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
username = options.get(self.UserModel.USERNAME_FIELD, None)
|
username = options.get(self.UserModel.USERNAME_FIELD)
|
||||||
database = options.get('database')
|
database = options.get('database')
|
||||||
|
|
||||||
# If not provided, create the user with an unusable password
|
# If not provided, create the user with an unusable password
|
||||||
|
|
|
@ -35,8 +35,8 @@ class FlatpageForm(forms.ModelForm):
|
||||||
return url
|
return url
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
url = self.cleaned_data.get('url', None)
|
url = self.cleaned_data.get('url')
|
||||||
sites = self.cleaned_data.get('sites', None)
|
sites = self.cleaned_data.get('sites')
|
||||||
|
|
||||||
same_url = FlatPage.objects.filter(url=url)
|
same_url = FlatPage.objects.filter(url=url)
|
||||||
if self.instance.pk:
|
if self.instance.pk:
|
||||||
|
|
|
@ -32,7 +32,7 @@ class GeoQuerySet(QuerySet):
|
||||||
# Performing setup here rather than in `_spatial_attribute` so that
|
# Performing setup here rather than in `_spatial_attribute` so that
|
||||||
# we can get the units for `AreaField`.
|
# we can get the units for `AreaField`.
|
||||||
procedure_args, geo_field = self._spatial_setup(
|
procedure_args, geo_field = self._spatial_setup(
|
||||||
'area', field_name=kwargs.get('field_name', None))
|
'area', field_name=kwargs.get('field_name'))
|
||||||
s = {'procedure_args': procedure_args,
|
s = {'procedure_args': procedure_args,
|
||||||
'geo_field': geo_field,
|
'geo_field': geo_field,
|
||||||
'setup': False,
|
'setup': False,
|
||||||
|
@ -403,7 +403,7 @@ class GeoQuerySet(QuerySet):
|
||||||
"""
|
"""
|
||||||
if not isinstance(srid, six.integer_types):
|
if not isinstance(srid, six.integer_types):
|
||||||
raise TypeError('An integer SRID must be provided.')
|
raise TypeError('An integer SRID must be provided.')
|
||||||
field_name = kwargs.get('field_name', None)
|
field_name = kwargs.get('field_name')
|
||||||
self._spatial_setup('transform', field_name=field_name)
|
self._spatial_setup('transform', field_name=field_name)
|
||||||
self.query.add_context('transformed_srid', srid)
|
self.query.add_context('transformed_srid', srid)
|
||||||
return self._clone()
|
return self._clone()
|
||||||
|
@ -534,7 +534,7 @@ class GeoQuerySet(QuerySet):
|
||||||
if settings.get('setup', True):
|
if settings.get('setup', True):
|
||||||
default_args, geo_field = self._spatial_setup(
|
default_args, geo_field = self._spatial_setup(
|
||||||
att, desc=settings['desc'], field_name=field_name,
|
att, desc=settings['desc'], field_name=field_name,
|
||||||
geo_field_type=settings.get('geo_field_type', None))
|
geo_field_type=settings.get('geo_field_type'))
|
||||||
for k, v in six.iteritems(default_args):
|
for k, v in six.iteritems(default_args):
|
||||||
settings['procedure_args'].setdefault(k, v)
|
settings['procedure_args'].setdefault(k, v)
|
||||||
else:
|
else:
|
||||||
|
@ -563,7 +563,7 @@ class GeoQuerySet(QuerySet):
|
||||||
fmt = '%%(function)s(%s)' % settings['procedure_fmt']
|
fmt = '%%(function)s(%s)' % settings['procedure_fmt']
|
||||||
|
|
||||||
# If the result of this function needs to be converted.
|
# If the result of this function needs to be converted.
|
||||||
if settings.get('select_field', False):
|
if settings.get('select_field'):
|
||||||
select_field = settings['select_field']
|
select_field = settings['select_field']
|
||||||
if connection.ops.oracle:
|
if connection.ops.oracle:
|
||||||
select_field.empty_strings_allowed = False
|
select_field.empty_strings_allowed = False
|
||||||
|
@ -583,7 +583,7 @@ class GeoQuerySet(QuerySet):
|
||||||
DRY routine for GeoQuerySet distance attribute routines.
|
DRY routine for GeoQuerySet distance attribute routines.
|
||||||
"""
|
"""
|
||||||
# Setting up the distance procedure arguments.
|
# Setting up the distance procedure arguments.
|
||||||
procedure_args, geo_field = self._spatial_setup(func, field_name=kwargs.get('field_name', None))
|
procedure_args, geo_field = self._spatial_setup(func, field_name=kwargs.get('field_name'))
|
||||||
|
|
||||||
# If geodetic defaulting distance attribute to meters (Oracle and
|
# If geodetic defaulting distance attribute to meters (Oracle and
|
||||||
# PostGIS spherical distances return meters). Otherwise, use the
|
# PostGIS spherical distances return meters). Otherwise, use the
|
||||||
|
|
|
@ -36,7 +36,7 @@ class GeoFeedMixin(object):
|
||||||
This routine adds a GeoRSS XML element using the given item and handler.
|
This routine adds a GeoRSS XML element using the given item and handler.
|
||||||
"""
|
"""
|
||||||
# Getting the Geometry object.
|
# Getting the Geometry object.
|
||||||
geom = item.get('geometry', None)
|
geom = item.get('geometry')
|
||||||
if geom is not None:
|
if geom is not None:
|
||||||
if isinstance(geom, (list, tuple)):
|
if isinstance(geom, (list, tuple)):
|
||||||
# Special case if a tuple/list was passed in. The tuple may be
|
# Special case if a tuple/list was passed in. The tuple may be
|
||||||
|
|
|
@ -37,7 +37,7 @@ class OGRGeomType(object):
|
||||||
type_input = type_input.lower()
|
type_input = type_input.lower()
|
||||||
if type_input == 'geometry':
|
if type_input == 'geometry':
|
||||||
type_input = 'unknown'
|
type_input = 'unknown'
|
||||||
num = self._str_types.get(type_input, None)
|
num = self._str_types.get(type_input)
|
||||||
if num is None:
|
if num is None:
|
||||||
raise GDALException('Invalid OGR String Type "%s"' % type_input)
|
raise GDALException('Invalid OGR String Type "%s"' % type_input)
|
||||||
elif isinstance(type_input, int):
|
elif isinstance(type_input, int):
|
||||||
|
|
|
@ -89,7 +89,7 @@ class GeoIP(object):
|
||||||
|
|
||||||
# Getting the GeoIP data path.
|
# Getting the GeoIP data path.
|
||||||
if not path:
|
if not path:
|
||||||
path = GEOIP_SETTINGS.get('GEOIP_PATH', None)
|
path = GEOIP_SETTINGS.get('GEOIP_PATH')
|
||||||
if not path:
|
if not path:
|
||||||
raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
|
raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
|
||||||
if not isinstance(path, six.string_types):
|
if not isinstance(path, six.string_types):
|
||||||
|
|
|
@ -8,7 +8,7 @@ from django.conf import settings
|
||||||
GEOIP_SETTINGS = {key: getattr(settings, key)
|
GEOIP_SETTINGS = {key: getattr(settings, key)
|
||||||
for key in ('GEOIP_PATH', 'GEOIP_LIBRARY_PATH', 'GEOIP_COUNTRY', 'GEOIP_CITY')
|
for key in ('GEOIP_PATH', 'GEOIP_LIBRARY_PATH', 'GEOIP_COUNTRY', 'GEOIP_CITY')
|
||||||
if hasattr(settings, key)}
|
if hasattr(settings, key)}
|
||||||
lib_path = GEOIP_SETTINGS.get('GEOIP_LIBRARY_PATH', None)
|
lib_path = GEOIP_SETTINGS.get('GEOIP_LIBRARY_PATH')
|
||||||
|
|
||||||
# The shared library for the GeoIP C API. May be downloaded
|
# The shared library for the GeoIP C API. May be downloaded
|
||||||
# from http://www.maxmind.com/download/geoip/api/c/
|
# from http://www.maxmind.com/download/geoip/api/c/
|
||||||
|
|
|
@ -72,7 +72,7 @@ class LineString(ProjectInterpolateMixin, GEOSGeometry):
|
||||||
cs[i] = coords[i]
|
cs[i] = coords[i]
|
||||||
|
|
||||||
# If SRID was passed in with the keyword arguments
|
# If SRID was passed in with the keyword arguments
|
||||||
srid = kwargs.get('srid', None)
|
srid = kwargs.get('srid')
|
||||||
|
|
||||||
# Calling the base geometry initialization with the returned pointer
|
# Calling the base geometry initialization with the returned pointer
|
||||||
# from the function.
|
# from the function.
|
||||||
|
|
|
@ -112,7 +112,7 @@ class SplitArrayWidget(forms.Widget):
|
||||||
value = value or []
|
value = value or []
|
||||||
output = []
|
output = []
|
||||||
final_attrs = self.build_attrs(attrs)
|
final_attrs = self.build_attrs(attrs)
|
||||||
id_ = final_attrs.get('id', None)
|
id_ = final_attrs.get('id')
|
||||||
for i in range(max(len(value), self.size)):
|
for i in range(max(len(value), self.size)):
|
||||||
try:
|
try:
|
||||||
widget_value = value[i]
|
widget_value = value[i]
|
||||||
|
|
|
@ -20,7 +20,7 @@ class SessionStore(SessionBase):
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
try:
|
try:
|
||||||
session_data = self._cache.get(self.cache_key, None)
|
session_data = self._cache.get(self.cache_key)
|
||||||
except Exception:
|
except Exception:
|
||||||
# Some backends (e.g. memcache) raise an exception on invalid
|
# Some backends (e.g. memcache) raise an exception on invalid
|
||||||
# cache keys. If this happens, reset the session. See #17810.
|
# cache keys. If this happens, reset the session. See #17810.
|
||||||
|
|
|
@ -29,7 +29,7 @@ class SessionStore(DBStore):
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
try:
|
try:
|
||||||
data = self._cache.get(self.cache_key, None)
|
data = self._cache.get(self.cache_key)
|
||||||
except Exception:
|
except Exception:
|
||||||
# Some backends (e.g. memcache) raise an exception on invalid
|
# Some backends (e.g. memcache) raise an exception on invalid
|
||||||
# cache keys. If this happens, reset the session. See #17810.
|
# cache keys. If this happens, reset the session. See #17810.
|
||||||
|
|
|
@ -12,7 +12,7 @@ class SessionMiddleware(object):
|
||||||
self.SessionStore = engine.SessionStore
|
self.SessionStore = engine.SessionStore
|
||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)
|
session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME)
|
||||||
request.session = self.SessionStore(session_key)
|
request.session = self.SessionStore(session_key)
|
||||||
|
|
||||||
def process_response(self, request, response):
|
def process_response(self, request, response):
|
||||||
|
|
|
@ -112,8 +112,8 @@ class Sitemap(object):
|
||||||
all_items_lastmod = True # track if all items have a lastmod
|
all_items_lastmod = True # track if all items have a lastmod
|
||||||
for item in self.paginator.page(page).object_list:
|
for item in self.paginator.page(page).object_list:
|
||||||
loc = "%s://%s%s" % (protocol, domain, self.__get('location', item))
|
loc = "%s://%s%s" % (protocol, domain, self.__get('location', item))
|
||||||
priority = self.__get('priority', item, None)
|
priority = self.__get('priority', item)
|
||||||
lastmod = self.__get('lastmod', item, None)
|
lastmod = self.__get('lastmod', item)
|
||||||
if all_items_lastmod:
|
if all_items_lastmod:
|
||||||
all_items_lastmod = lastmod is not None
|
all_items_lastmod = lastmod is not None
|
||||||
if (all_items_lastmod and
|
if (all_items_lastmod and
|
||||||
|
@ -123,7 +123,7 @@ class Sitemap(object):
|
||||||
'item': item,
|
'item': item,
|
||||||
'location': loc,
|
'location': loc,
|
||||||
'lastmod': lastmod,
|
'lastmod': lastmod,
|
||||||
'changefreq': self.__get('changefreq', item, None),
|
'changefreq': self.__get('changefreq', item),
|
||||||
'priority': str(priority if priority is not None else ''),
|
'priority': str(priority if priority is not None else ''),
|
||||||
}
|
}
|
||||||
urls.append(url_info)
|
urls.append(url_info)
|
||||||
|
@ -138,7 +138,7 @@ class GenericSitemap(Sitemap):
|
||||||
|
|
||||||
def __init__(self, info_dict, priority=None, changefreq=None):
|
def __init__(self, info_dict, priority=None, changefreq=None):
|
||||||
self.queryset = info_dict['queryset']
|
self.queryset = info_dict['queryset']
|
||||||
self.date_field = info_dict.get('date_field', None)
|
self.date_field = info_dict.get('date_field')
|
||||||
self.priority = priority
|
self.priority = priority
|
||||||
self.changefreq = changefreq
|
self.changefreq = changefreq
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ class AppDirectoriesFinder(BaseFinder):
|
||||||
"""
|
"""
|
||||||
Find a requested static file in an app's static locations.
|
Find a requested static file in an app's static locations.
|
||||||
"""
|
"""
|
||||||
storage = self.storages.get(app, None)
|
storage = self.storages.get(app)
|
||||||
if storage:
|
if storage:
|
||||||
# only try to find a file if the source dir actually exists
|
# only try to find a file if the source dir actually exists
|
||||||
if storage.exists(path):
|
if storage.exists(path):
|
||||||
|
|
|
@ -308,7 +308,7 @@ class ManifestFilesMixin(HashedFilesMixin):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
version = stored.get('version', None)
|
version = stored.get('version')
|
||||||
if version == '1.0':
|
if version == '1.0':
|
||||||
return stored.get('paths', OrderedDict())
|
return stored.get('paths', OrderedDict())
|
||||||
raise ValueError("Couldn't load manifest '%s' (version %s)" %
|
raise ValueError("Couldn't load manifest '%s' (version %s)" %
|
||||||
|
@ -341,7 +341,7 @@ class _MappingCache(object):
|
||||||
self.cache.set(key, value)
|
self.cache.set(key, value)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
value = self.cache.get(key, None)
|
value = self.cache.get(key)
|
||||||
if value is None:
|
if value is None:
|
||||||
raise KeyError("Couldn't find a file name '%s'" % key)
|
raise KeyError("Couldn't find a file name '%s'" % key)
|
||||||
return value
|
return value
|
||||||
|
|
|
@ -74,7 +74,7 @@ class BaseCache(object):
|
||||||
|
|
||||||
self.key_prefix = params.get('KEY_PREFIX', '')
|
self.key_prefix = params.get('KEY_PREFIX', '')
|
||||||
self.version = params.get('VERSION', 1)
|
self.version = params.get('VERSION', 1)
|
||||||
self.key_func = get_key_func(params.get('KEY_FUNCTION', None))
|
self.key_func = get_key_func(params.get('KEY_FUNCTION'))
|
||||||
|
|
||||||
def get_backend_timeout(self, timeout=DEFAULT_TIMEOUT):
|
def get_backend_timeout(self, timeout=DEFAULT_TIMEOUT):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -24,7 +24,7 @@ class BaseMemcachedCache(BaseCache):
|
||||||
self.LibraryValueNotFoundException = value_not_found_exception
|
self.LibraryValueNotFoundException = value_not_found_exception
|
||||||
|
|
||||||
self._lib = library
|
self._lib = library
|
||||||
self._options = params.get('OPTIONS', None)
|
self._options = params.get('OPTIONS')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _cache(self):
|
def _cache(self):
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Command(BaseCommand):
|
||||||
else:
|
else:
|
||||||
app_configs = None
|
app_configs = None
|
||||||
|
|
||||||
tags = options.get('tags', None)
|
tags = options.get('tags')
|
||||||
if tags:
|
if tags:
|
||||||
try:
|
try:
|
||||||
invalid_tag = next(
|
invalid_tag = next(
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Command(BaseCommand):
|
||||||
self.dry_run = options.get('dry_run', False)
|
self.dry_run = options.get('dry_run', False)
|
||||||
self.merge = options.get('merge', False)
|
self.merge = options.get('merge', False)
|
||||||
self.empty = options.get('empty', False)
|
self.empty = options.get('empty', False)
|
||||||
self.migration_name = options.get('name', None)
|
self.migration_name = options.get('name')
|
||||||
self.exit_code = options.get('exit_code', False)
|
self.exit_code = options.get('exit_code', False)
|
||||||
|
|
||||||
# Make sure the app they asked for exists
|
# Make sure the app they asked for exists
|
||||||
|
@ -165,7 +165,7 @@ class Command(BaseCommand):
|
||||||
if not self.dry_run:
|
if not self.dry_run:
|
||||||
# Write the migrations file to the disk.
|
# Write the migrations file to the disk.
|
||||||
migrations_directory = os.path.dirname(writer.path)
|
migrations_directory = os.path.dirname(writer.path)
|
||||||
if not directory_created.get(app_label, False):
|
if not directory_created.get(app_label):
|
||||||
if not os.path.isdir(migrations_directory):
|
if not os.path.isdir(migrations_directory):
|
||||||
os.mkdir(migrations_directory)
|
os.mkdir(migrations_directory)
|
||||||
init_path = os.path.join(migrations_directory, "__init__.py")
|
init_path = os.path.join(migrations_directory, "__init__.py")
|
||||||
|
|
|
@ -23,8 +23,8 @@ class Serializer(base.Serializer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def indent(self, level):
|
def indent(self, level):
|
||||||
if self.options.get('indent', None) is not None:
|
if self.options.get('indent') is not None:
|
||||||
self.xml.ignorableWhitespace('\n' + ' ' * self.options.get('indent', None) * level)
|
self.xml.ignorableWhitespace('\n' + ' ' * self.options.get('indent') * level)
|
||||||
|
|
||||||
def start_serialization(self):
|
def start_serialization(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -591,7 +591,7 @@ class MigrationAutodetector(object):
|
||||||
added = set(self.new_proxy_keys) - set(self.old_proxy_keys)
|
added = set(self.new_proxy_keys) - set(self.old_proxy_keys)
|
||||||
for app_label, model_name in sorted(added):
|
for app_label, model_name in sorted(added):
|
||||||
model_state = self.to_state.models[app_label, model_name]
|
model_state = self.to_state.models[app_label, model_name]
|
||||||
assert model_state.options.get("proxy", False)
|
assert model_state.options.get("proxy")
|
||||||
# Depend on the deletion of any possible non-proxy version of us
|
# Depend on the deletion of any possible non-proxy version of us
|
||||||
dependencies = [
|
dependencies = [
|
||||||
(app_label, model_name, None, False),
|
(app_label, model_name, None, False),
|
||||||
|
@ -695,7 +695,7 @@ class MigrationAutodetector(object):
|
||||||
for name, field in sorted(related_fields.items()):
|
for name, field in sorted(related_fields.items()):
|
||||||
dependencies.append((app_label, model_name, name, False))
|
dependencies.append((app_label, model_name, name, False))
|
||||||
# We're referenced in another field's through=
|
# We're referenced in another field's through=
|
||||||
through_user = self.through_users.get((app_label, model_state.name_lower), None)
|
through_user = self.through_users.get((app_label, model_state.name_lower))
|
||||||
if through_user:
|
if through_user:
|
||||||
dependencies.append((through_user[0], through_user[1], through_user[2], False))
|
dependencies.append((through_user[0], through_user[1], through_user[2], False))
|
||||||
# Finally, make the operation, deduping any dependencies
|
# Finally, make the operation, deduping any dependencies
|
||||||
|
@ -714,7 +714,7 @@ class MigrationAutodetector(object):
|
||||||
deleted = set(self.old_proxy_keys) - set(self.new_proxy_keys)
|
deleted = set(self.old_proxy_keys) - set(self.new_proxy_keys)
|
||||||
for app_label, model_name in sorted(deleted):
|
for app_label, model_name in sorted(deleted):
|
||||||
model_state = self.from_state.models[app_label, model_name]
|
model_state = self.from_state.models[app_label, model_name]
|
||||||
assert model_state.options.get("proxy", False)
|
assert model_state.options.get("proxy")
|
||||||
self.add_operation(
|
self.add_operation(
|
||||||
app_label,
|
app_label,
|
||||||
operations.DeleteModel(
|
operations.DeleteModel(
|
||||||
|
@ -980,12 +980,12 @@ class MigrationAutodetector(object):
|
||||||
old_model_name = self.renamed_models.get((app_label, model_name), model_name)
|
old_model_name = self.renamed_models.get((app_label, model_name), model_name)
|
||||||
old_model_state = self.from_state.models[app_label, old_model_name]
|
old_model_state = self.from_state.models[app_label, old_model_name]
|
||||||
new_model_state = self.to_state.models[app_label, model_name]
|
new_model_state = self.to_state.models[app_label, model_name]
|
||||||
if (old_model_state.options.get("order_with_respect_to", None) !=
|
if (old_model_state.options.get("order_with_respect_to") !=
|
||||||
new_model_state.options.get("order_with_respect_to", None)):
|
new_model_state.options.get("order_with_respect_to")):
|
||||||
# Make sure it comes second if we're adding
|
# Make sure it comes second if we're adding
|
||||||
# (removal dependency is part of RemoveField)
|
# (removal dependency is part of RemoveField)
|
||||||
dependencies = []
|
dependencies = []
|
||||||
if new_model_state.options.get("order_with_respect_to", None):
|
if new_model_state.options.get("order_with_respect_to"):
|
||||||
dependencies.append((
|
dependencies.append((
|
||||||
app_label,
|
app_label,
|
||||||
model_name,
|
model_name,
|
||||||
|
@ -997,7 +997,7 @@ class MigrationAutodetector(object):
|
||||||
app_label,
|
app_label,
|
||||||
operations.AlterOrderWithRespectTo(
|
operations.AlterOrderWithRespectTo(
|
||||||
name=model_name,
|
name=model_name,
|
||||||
order_with_respect_to=new_model_state.options.get('order_with_respect_to', None),
|
order_with_respect_to=new_model_state.options.get('order_with_respect_to'),
|
||||||
),
|
),
|
||||||
dependencies=dependencies,
|
dependencies=dependencies,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1739,7 +1739,7 @@ class FilePathField(Field):
|
||||||
kwargs['allow_files'] = self.allow_files
|
kwargs['allow_files'] = self.allow_files
|
||||||
if self.allow_folders is not False:
|
if self.allow_folders is not False:
|
||||||
kwargs['allow_folders'] = self.allow_folders
|
kwargs['allow_folders'] = self.allow_folders
|
||||||
if kwargs.get("max_length", None) == 100:
|
if kwargs.get("max_length") == 100:
|
||||||
del kwargs["max_length"]
|
del kwargs["max_length"]
|
||||||
return name, path, args, kwargs
|
return name, path, args, kwargs
|
||||||
|
|
||||||
|
@ -1955,7 +1955,7 @@ class GenericIPAddressField(Field):
|
||||||
kwargs['unpack_ipv4'] = self.unpack_ipv4
|
kwargs['unpack_ipv4'] = self.unpack_ipv4
|
||||||
if self.protocol != "both":
|
if self.protocol != "both":
|
||||||
kwargs['protocol'] = self.protocol
|
kwargs['protocol'] = self.protocol
|
||||||
if kwargs.get("max_length", None) == 39:
|
if kwargs.get("max_length") == 39:
|
||||||
del kwargs['max_length']
|
del kwargs['max_length']
|
||||||
return name, path, args, kwargs
|
return name, path, args, kwargs
|
||||||
|
|
||||||
|
@ -2099,7 +2099,7 @@ class SlugField(CharField):
|
||||||
|
|
||||||
def deconstruct(self):
|
def deconstruct(self):
|
||||||
name, path, args, kwargs = super(SlugField, self).deconstruct()
|
name, path, args, kwargs = super(SlugField, self).deconstruct()
|
||||||
if kwargs.get("max_length", None) == 50:
|
if kwargs.get("max_length") == 50:
|
||||||
del kwargs['max_length']
|
del kwargs['max_length']
|
||||||
if self.db_index is False:
|
if self.db_index is False:
|
||||||
kwargs['db_index'] = False
|
kwargs['db_index'] = False
|
||||||
|
@ -2288,7 +2288,7 @@ class URLField(CharField):
|
||||||
|
|
||||||
def deconstruct(self):
|
def deconstruct(self):
|
||||||
name, path, args, kwargs = super(URLField, self).deconstruct()
|
name, path, args, kwargs = super(URLField, self).deconstruct()
|
||||||
if kwargs.get("max_length", None) == 200:
|
if kwargs.get("max_length") == 200:
|
||||||
del kwargs['max_length']
|
del kwargs['max_length']
|
||||||
return name, path, args, kwargs
|
return name, path, args, kwargs
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ class FileField(Field):
|
||||||
|
|
||||||
def deconstruct(self):
|
def deconstruct(self):
|
||||||
name, path, args, kwargs = super(FileField, self).deconstruct()
|
name, path, args, kwargs = super(FileField, self).deconstruct()
|
||||||
if kwargs.get("max_length", None) == 100:
|
if kwargs.get("max_length") == 100:
|
||||||
del kwargs["max_length"]
|
del kwargs["max_length"]
|
||||||
kwargs['upload_to'] = self.upload_to
|
kwargs['upload_to'] = self.upload_to
|
||||||
if self.storage is not default_storage:
|
if self.storage is not default_storage:
|
||||||
|
|
|
@ -1216,7 +1216,7 @@ class RawQuerySet(object):
|
||||||
model_cls = deferred_class_factory(self.model, skip)
|
model_cls = deferred_class_factory(self.model, skip)
|
||||||
else:
|
else:
|
||||||
model_cls = self.model
|
model_cls = self.model
|
||||||
fields = [self.model_fields.get(c, None) for c in self.columns]
|
fields = [self.model_fields.get(c) for c in self.columns]
|
||||||
converters = compiler.get_converters([
|
converters = compiler.get_converters([
|
||||||
f.get_col(f.model._meta.db_table) if f else None for f in fields
|
f.get_col(f.model._meta.db_table) if f else None for f in fields
|
||||||
])
|
])
|
||||||
|
|
|
@ -378,7 +378,7 @@ class BaseModelForm(BaseForm):
|
||||||
# from validation.
|
# from validation.
|
||||||
else:
|
else:
|
||||||
form_field = self.fields[field]
|
form_field = self.fields[field]
|
||||||
field_value = self.cleaned_data.get(field, None)
|
field_value = self.cleaned_data.get(field)
|
||||||
if not f.blank and not form_field.required and field_value in form_field.empty_values:
|
if not f.blank and not form_field.required and field_value in form_field.empty_values:
|
||||||
exclude.append(f.name)
|
exclude.append(f.name)
|
||||||
return exclude
|
return exclude
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Media(object):
|
||||||
self._js = []
|
self._js = []
|
||||||
|
|
||||||
for name in MEDIA_TYPES:
|
for name in MEDIA_TYPES:
|
||||||
getattr(self, 'add_' + name)(media_attrs.get(name, None))
|
getattr(self, 'add_' + name)(media_attrs.get(name))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.render()
|
return self.render()
|
||||||
|
@ -228,7 +228,7 @@ class Widget(six.with_metaclass(MediaDefiningClass)):
|
||||||
Given a dictionary of data and this widget's name, returns the value
|
Given a dictionary of data and this widget's name, returns the value
|
||||||
of this widget. Returns None if it's not provided.
|
of this widget. Returns None if it's not provided.
|
||||||
"""
|
"""
|
||||||
return data.get(name, None)
|
return data.get(name)
|
||||||
|
|
||||||
def id_for_label(self, id_):
|
def id_for_label(self, id_):
|
||||||
"""
|
"""
|
||||||
|
@ -317,7 +317,7 @@ class MultipleHiddenInput(HiddenInput):
|
||||||
if value is None:
|
if value is None:
|
||||||
value = []
|
value = []
|
||||||
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
|
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
|
||||||
id_ = final_attrs.get('id', None)
|
id_ = final_attrs.get('id')
|
||||||
inputs = []
|
inputs = []
|
||||||
for i, v in enumerate(value):
|
for i, v in enumerate(value):
|
||||||
input_attrs = dict(value=force_text(v), **final_attrs)
|
input_attrs = dict(value=force_text(v), **final_attrs)
|
||||||
|
@ -331,7 +331,7 @@ class MultipleHiddenInput(HiddenInput):
|
||||||
def value_from_datadict(self, data, files, name):
|
def value_from_datadict(self, data, files, name):
|
||||||
if isinstance(data, MultiValueDict):
|
if isinstance(data, MultiValueDict):
|
||||||
return data.getlist(name)
|
return data.getlist(name)
|
||||||
return data.get(name, None)
|
return data.get(name)
|
||||||
|
|
||||||
|
|
||||||
class FileInput(Input):
|
class FileInput(Input):
|
||||||
|
@ -343,7 +343,7 @@ class FileInput(Input):
|
||||||
|
|
||||||
def value_from_datadict(self, data, files, name):
|
def value_from_datadict(self, data, files, name):
|
||||||
"File widgets take data from FILES, not POST"
|
"File widgets take data from FILES, not POST"
|
||||||
return files.get(name, None)
|
return files.get(name)
|
||||||
|
|
||||||
|
|
||||||
FILE_INPUT_CONTRADICTION = object()
|
FILE_INPUT_CONTRADICTION = object()
|
||||||
|
@ -581,13 +581,13 @@ class NullBooleanSelect(Select):
|
||||||
return super(NullBooleanSelect, self).render(name, value, attrs, choices)
|
return super(NullBooleanSelect, self).render(name, value, attrs, choices)
|
||||||
|
|
||||||
def value_from_datadict(self, data, files, name):
|
def value_from_datadict(self, data, files, name):
|
||||||
value = data.get(name, None)
|
value = data.get(name)
|
||||||
return {'2': True,
|
return {'2': True,
|
||||||
True: True,
|
True: True,
|
||||||
'True': True,
|
'True': True,
|
||||||
'3': False,
|
'3': False,
|
||||||
'False': False,
|
'False': False,
|
||||||
False: False}.get(value, None)
|
False: False}.get(value)
|
||||||
|
|
||||||
|
|
||||||
class SelectMultiple(Select):
|
class SelectMultiple(Select):
|
||||||
|
@ -607,7 +607,7 @@ class SelectMultiple(Select):
|
||||||
def value_from_datadict(self, data, files, name):
|
def value_from_datadict(self, data, files, name):
|
||||||
if isinstance(data, MultiValueDict):
|
if isinstance(data, MultiValueDict):
|
||||||
return data.getlist(name)
|
return data.getlist(name)
|
||||||
return data.get(name, None)
|
return data.get(name)
|
||||||
|
|
||||||
|
|
||||||
@html_safe
|
@html_safe
|
||||||
|
@ -706,7 +706,7 @@ class ChoiceFieldRenderer(object):
|
||||||
If an id was given to the field, it is applied to the <ul> (each
|
If an id was given to the field, it is applied to the <ul> (each
|
||||||
item in the list will get an id of `$id_$i`).
|
item in the list will get an id of `$id_$i`).
|
||||||
"""
|
"""
|
||||||
id_ = self.attrs.get('id', None)
|
id_ = self.attrs.get('id')
|
||||||
output = []
|
output = []
|
||||||
for i, choice in enumerate(self.choices):
|
for i, choice in enumerate(self.choices):
|
||||||
choice_value, choice_label = choice
|
choice_value, choice_label = choice
|
||||||
|
@ -831,7 +831,7 @@ class MultiWidget(Widget):
|
||||||
value = self.decompress(value)
|
value = self.decompress(value)
|
||||||
output = []
|
output = []
|
||||||
final_attrs = self.build_attrs(attrs)
|
final_attrs = self.build_attrs(attrs)
|
||||||
id_ = final_attrs.get('id', None)
|
id_ = final_attrs.get('id')
|
||||||
for i, widget in enumerate(self.widgets):
|
for i, widget in enumerate(self.widgets):
|
||||||
try:
|
try:
|
||||||
widget_value = value[i]
|
widget_value = value[i]
|
||||||
|
@ -1031,7 +1031,7 @@ class SelectDateWidget(Widget):
|
||||||
return date_value.strftime(input_format)
|
return date_value.strftime(input_format)
|
||||||
else:
|
else:
|
||||||
return '%s-%s-%s' % (y, m, d)
|
return '%s-%s-%s' % (y, m, d)
|
||||||
return data.get(name, None)
|
return data.get(name)
|
||||||
|
|
||||||
def create_select(self, name, field, value, val, choices, none_value):
|
def create_select(self, name, field, value, val, choices, none_value):
|
||||||
if 'id' in self.attrs:
|
if 'id' in self.attrs:
|
||||||
|
|
|
@ -172,7 +172,7 @@ class HttpRequest(object):
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
|
'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
|
||||||
)
|
)
|
||||||
if self.META.get(header, None) == value:
|
if self.META.get(header) == value:
|
||||||
return 'https'
|
return 'https'
|
||||||
return self._get_scheme()
|
return self._get_scheme()
|
||||||
|
|
||||||
|
|
|
@ -131,11 +131,11 @@ class FetchFromCacheMiddleware(object):
|
||||||
if cache_key is None:
|
if cache_key is None:
|
||||||
request._cache_update_cache = True
|
request._cache_update_cache = True
|
||||||
return None # No cache information available, need to rebuild.
|
return None # No cache information available, need to rebuild.
|
||||||
response = self.cache.get(cache_key, None)
|
response = self.cache.get(cache_key)
|
||||||
# if it wasn't found and we are looking for a HEAD, try looking just for that
|
# if it wasn't found and we are looking for a HEAD, try looking just for that
|
||||||
if response is None and request.method == 'HEAD':
|
if response is None and request.method == 'HEAD':
|
||||||
cache_key = get_cache_key(request, self.key_prefix, 'HEAD', cache=self.cache)
|
cache_key = get_cache_key(request, self.key_prefix, 'HEAD', cache=self.cache)
|
||||||
response = self.cache.get(cache_key, None)
|
response = self.cache.get(cache_key)
|
||||||
|
|
||||||
if response is None:
|
if response is None:
|
||||||
request._cache_update_cache = True
|
request._cache_update_cache = True
|
||||||
|
|
|
@ -28,7 +28,7 @@ class XFrameOptionsMiddleware(object):
|
||||||
"""
|
"""
|
||||||
def process_response(self, request, response):
|
def process_response(self, request, response):
|
||||||
# Don't set it if it's already in the response
|
# Don't set it if it's already in the response
|
||||||
if response.get('X-Frame-Options', None) is not None:
|
if response.get('X-Frame-Options') is not None:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Don't set it if they used @xframe_options_exempt
|
# Don't set it if they used @xframe_options_exempt
|
||||||
|
|
|
@ -1325,7 +1325,7 @@ class Library(object):
|
||||||
# inclusion tags are often used for forms, and we need
|
# inclusion tags are often used for forms, and we need
|
||||||
# instructions for using CSRF protection to be as simple
|
# instructions for using CSRF protection to be as simple
|
||||||
# as possible.
|
# as possible.
|
||||||
csrf_token = context.get('csrf_token', None)
|
csrf_token = context.get('csrf_token')
|
||||||
if csrf_token is not None:
|
if csrf_token is not None:
|
||||||
new_context['csrf_token'] = csrf_token
|
new_context['csrf_token'] = csrf_token
|
||||||
return t.render(new_context)
|
return t.render(new_context)
|
||||||
|
@ -1421,7 +1421,7 @@ def get_library(library_name):
|
||||||
Subsequent loads eg. {% load somelib %} in the same process will grab
|
Subsequent loads eg. {% load somelib %} in the same process will grab
|
||||||
the cached module from libraries.
|
the cached module from libraries.
|
||||||
"""
|
"""
|
||||||
lib = libraries.get(library_name, None)
|
lib = libraries.get(library_name)
|
||||||
if not lib:
|
if not lib:
|
||||||
templatetags_modules = get_templatetags_modules()
|
templatetags_modules = get_templatetags_modules()
|
||||||
tried_modules = []
|
tried_modules = []
|
||||||
|
|
|
@ -53,7 +53,7 @@ class CommentNode(Node):
|
||||||
|
|
||||||
class CsrfTokenNode(Node):
|
class CsrfTokenNode(Node):
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
csrf_token = context.get('csrf_token', None)
|
csrf_token = context.get('csrf_token')
|
||||||
if csrf_token:
|
if csrf_token:
|
||||||
if csrf_token == 'NOTPROVIDED':
|
if csrf_token == 'NOTPROVIDED':
|
||||||
return format_html("")
|
return format_html("")
|
||||||
|
|
|
@ -414,7 +414,7 @@ class Client(RequestFactory):
|
||||||
"""
|
"""
|
||||||
if apps.is_installed('django.contrib.sessions'):
|
if apps.is_installed('django.contrib.sessions'):
|
||||||
engine = import_module(settings.SESSION_ENGINE)
|
engine = import_module(settings.SESSION_ENGINE)
|
||||||
cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None)
|
cookie = self.cookies.get(settings.SESSION_COOKIE_NAME)
|
||||||
if cookie:
|
if cookie:
|
||||||
return engine.SessionStore(cookie.value)
|
return engine.SessionStore(cookie.value)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -189,7 +189,7 @@ def _generate_cache_key(request, method, headerlist, key_prefix):
|
||||||
"""Returns a cache key from the headers given in the header list."""
|
"""Returns a cache key from the headers given in the header list."""
|
||||||
ctx = hashlib.md5()
|
ctx = hashlib.md5()
|
||||||
for header in headerlist:
|
for header in headerlist:
|
||||||
value = request.META.get(header, None)
|
value = request.META.get(header)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
ctx.update(force_bytes(value))
|
ctx.update(force_bytes(value))
|
||||||
url = hashlib.md5(force_bytes(iri_to_uri(request.build_absolute_uri())))
|
url = hashlib.md5(force_bytes(iri_to_uri(request.build_absolute_uri())))
|
||||||
|
@ -221,7 +221,7 @@ def get_cache_key(request, key_prefix=None, method='GET', cache=None):
|
||||||
cache_key = _generate_cache_header_key(key_prefix, request)
|
cache_key = _generate_cache_header_key(key_prefix, request)
|
||||||
if cache is None:
|
if cache is None:
|
||||||
cache = caches[settings.CACHE_MIDDLEWARE_ALIAS]
|
cache = caches[settings.CACHE_MIDDLEWARE_ALIAS]
|
||||||
headerlist = cache.get(cache_key, None)
|
headerlist = cache.get(cache_key)
|
||||||
if headerlist is not None:
|
if headerlist is not None:
|
||||||
return _generate_cache_key(request, method, headerlist, key_prefix)
|
return _generate_cache_key(request, method, headerlist, key_prefix)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -18,7 +18,7 @@ def xframe_options_deny(view_func):
|
||||||
"""
|
"""
|
||||||
def wrapped_view(*args, **kwargs):
|
def wrapped_view(*args, **kwargs):
|
||||||
resp = view_func(*args, **kwargs)
|
resp = view_func(*args, **kwargs)
|
||||||
if resp.get('X-Frame-Options', None) is None:
|
if resp.get('X-Frame-Options') is None:
|
||||||
resp['X-Frame-Options'] = 'DENY'
|
resp['X-Frame-Options'] = 'DENY'
|
||||||
return resp
|
return resp
|
||||||
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)
|
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)
|
||||||
|
@ -39,7 +39,7 @@ def xframe_options_sameorigin(view_func):
|
||||||
"""
|
"""
|
||||||
def wrapped_view(*args, **kwargs):
|
def wrapped_view(*args, **kwargs):
|
||||||
resp = view_func(*args, **kwargs)
|
resp = view_func(*args, **kwargs)
|
||||||
if resp.get('X-Frame-Options', None) is None:
|
if resp.get('X-Frame-Options') is None:
|
||||||
resp['X-Frame-Options'] = 'SAMEORIGIN'
|
resp['X-Frame-Options'] = 'SAMEORIGIN'
|
||||||
return resp
|
return resp
|
||||||
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)
|
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)
|
||||||
|
|
|
@ -32,8 +32,8 @@ class SingleObjectMixin(ContextMixin):
|
||||||
queryset = self.get_queryset()
|
queryset = self.get_queryset()
|
||||||
|
|
||||||
# Next, try looking up by primary key.
|
# Next, try looking up by primary key.
|
||||||
pk = self.kwargs.get(self.pk_url_kwarg, None)
|
pk = self.kwargs.get(self.pk_url_kwarg)
|
||||||
slug = self.kwargs.get(self.slug_url_kwarg, None)
|
slug = self.kwargs.get(self.slug_url_kwarg)
|
||||||
if pk is not None:
|
if pk is not None:
|
||||||
queryset = queryset.filter(pk=pk)
|
queryset = queryset.filter(pk=pk)
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ def set_language(request):
|
||||||
next = '/'
|
next = '/'
|
||||||
response = http.HttpResponseRedirect(next)
|
response = http.HttpResponseRedirect(next)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
lang_code = request.POST.get('language', None)
|
lang_code = request.POST.get('language')
|
||||||
if lang_code and check_for_language(lang_code):
|
if lang_code and check_for_language(lang_code):
|
||||||
next_trans = translate_url(next, lang_code)
|
next_trans = translate_url(next, lang_code)
|
||||||
if next_trans != next:
|
if next_trans != next:
|
||||||
|
|
Loading…
Reference in New Issue