Removed unnecessary arguments in .get method calls

This commit is contained in:
Piotr Jakimiak 2015-05-13 20:51:18 +02:00
parent f61c4f490d
commit 4157c502a5
39 changed files with 78 additions and 79 deletions

View File

@ -85,7 +85,7 @@ class SimpleListFilter(ListFilter):
query string for this filter, if any. If the value wasn't provided then
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):
"""
@ -220,8 +220,8 @@ class BooleanFieldListFilter(FieldListFilter):
def __init__(self, field, request, params, model, model_admin, field_path):
self.lookup_kwarg = '%s__exact' % field_path
self.lookup_kwarg2 = '%s__isnull' % field_path
self.lookup_val = request.GET.get(self.lookup_kwarg, None)
self.lookup_val2 = request.GET.get(self.lookup_kwarg2, None)
self.lookup_val = request.GET.get(self.lookup_kwarg)
self.lookup_val2 = request.GET.get(self.lookup_kwarg2)
super(BooleanFieldListFilter, self).__init__(field,
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):
self.lookup_kwarg = field_path
self.lookup_kwarg_isnull = '%s__isnull' % field_path
self.lookup_val = request.GET.get(self.lookup_kwarg, None)
self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull,
None)
self.lookup_val = request.GET.get(self.lookup_kwarg)
self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull)
parent_model, reverse_path = reverse_field_path(model, field_path)
# Obey parent ModelAdmin queryset when deciding which options to show
if model == parent_model:

View File

@ -200,7 +200,7 @@ class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)):
ordering. Otherwise don't specify the queryset, let the field decide
(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:
ordering = related_admin.get_ordering(request)
if ordering is not None and ordering != ():

View File

@ -106,7 +106,7 @@ class UserChangeForm(forms.ModelForm):
def __init__(self, *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:
f.queryset = f.queryset.select_related('content_type')

View File

@ -50,7 +50,7 @@ class Command(BaseCommand):
return super(Command, self).execute(*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')
# If not provided, create the user with an unusable password

View File

@ -35,8 +35,8 @@ class FlatpageForm(forms.ModelForm):
return url
def clean(self):
url = self.cleaned_data.get('url', None)
sites = self.cleaned_data.get('sites', None)
url = self.cleaned_data.get('url')
sites = self.cleaned_data.get('sites')
same_url = FlatPage.objects.filter(url=url)
if self.instance.pk:

View File

@ -32,7 +32,7 @@ class GeoQuerySet(QuerySet):
# Performing setup here rather than in `_spatial_attribute` so that
# we can get the units for `AreaField`.
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,
'geo_field': geo_field,
'setup': False,
@ -403,7 +403,7 @@ class GeoQuerySet(QuerySet):
"""
if not isinstance(srid, six.integer_types):
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.query.add_context('transformed_srid', srid)
return self._clone()
@ -534,7 +534,7 @@ class GeoQuerySet(QuerySet):
if settings.get('setup', True):
default_args, geo_field = self._spatial_setup(
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):
settings['procedure_args'].setdefault(k, v)
else:
@ -563,7 +563,7 @@ class GeoQuerySet(QuerySet):
fmt = '%%(function)s(%s)' % settings['procedure_fmt']
# 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']
if connection.ops.oracle:
select_field.empty_strings_allowed = False
@ -583,7 +583,7 @@ class GeoQuerySet(QuerySet):
DRY routine for GeoQuerySet distance attribute routines.
"""
# 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
# PostGIS spherical distances return meters). Otherwise, use the

View File

@ -36,7 +36,7 @@ class GeoFeedMixin(object):
This routine adds a GeoRSS XML element using the given item and handler.
"""
# Getting the Geometry object.
geom = item.get('geometry', None)
geom = item.get('geometry')
if geom is not None:
if isinstance(geom, (list, tuple)):
# Special case if a tuple/list was passed in. The tuple may be

View File

@ -37,7 +37,7 @@ class OGRGeomType(object):
type_input = type_input.lower()
if type_input == 'geometry':
type_input = 'unknown'
num = self._str_types.get(type_input, None)
num = self._str_types.get(type_input)
if num is None:
raise GDALException('Invalid OGR String Type "%s"' % type_input)
elif isinstance(type_input, int):

View File

@ -89,7 +89,7 @@ class GeoIP(object):
# Getting the GeoIP data path.
if not path:
path = GEOIP_SETTINGS.get('GEOIP_PATH', None)
path = GEOIP_SETTINGS.get('GEOIP_PATH')
if not path:
raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
if not isinstance(path, six.string_types):

View File

@ -8,7 +8,7 @@ from django.conf import settings
GEOIP_SETTINGS = {key: getattr(settings, key)
for key in ('GEOIP_PATH', 'GEOIP_LIBRARY_PATH', 'GEOIP_COUNTRY', 'GEOIP_CITY')
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
# from http://www.maxmind.com/download/geoip/api/c/

View File

@ -72,7 +72,7 @@ class LineString(ProjectInterpolateMixin, GEOSGeometry):
cs[i] = coords[i]
# 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
# from the function.

View File

@ -112,7 +112,7 @@ class SplitArrayWidget(forms.Widget):
value = value or []
output = []
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)):
try:
widget_value = value[i]

View File

@ -20,7 +20,7 @@ class SessionStore(SessionBase):
def load(self):
try:
session_data = self._cache.get(self.cache_key, None)
session_data = self._cache.get(self.cache_key)
except Exception:
# Some backends (e.g. memcache) raise an exception on invalid
# cache keys. If this happens, reset the session. See #17810.

View File

@ -29,7 +29,7 @@ class SessionStore(DBStore):
def load(self):
try:
data = self._cache.get(self.cache_key, None)
data = self._cache.get(self.cache_key)
except Exception:
# Some backends (e.g. memcache) raise an exception on invalid
# cache keys. If this happens, reset the session. See #17810.

View File

@ -12,7 +12,7 @@ class SessionMiddleware(object):
self.SessionStore = engine.SessionStore
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)
def process_response(self, request, response):

View File

@ -112,8 +112,8 @@ class Sitemap(object):
all_items_lastmod = True # track if all items have a lastmod
for item in self.paginator.page(page).object_list:
loc = "%s://%s%s" % (protocol, domain, self.__get('location', item))
priority = self.__get('priority', item, None)
lastmod = self.__get('lastmod', item, None)
priority = self.__get('priority', item)
lastmod = self.__get('lastmod', item)
if all_items_lastmod:
all_items_lastmod = lastmod is not None
if (all_items_lastmod and
@ -123,7 +123,7 @@ class Sitemap(object):
'item': item,
'location': loc,
'lastmod': lastmod,
'changefreq': self.__get('changefreq', item, None),
'changefreq': self.__get('changefreq', item),
'priority': str(priority if priority is not None else ''),
}
urls.append(url_info)
@ -138,7 +138,7 @@ class GenericSitemap(Sitemap):
def __init__(self, info_dict, priority=None, changefreq=None):
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.changefreq = changefreq

View File

@ -168,7 +168,7 @@ class AppDirectoriesFinder(BaseFinder):
"""
Find a requested static file in an app's static locations.
"""
storage = self.storages.get(app, None)
storage = self.storages.get(app)
if storage:
# only try to find a file if the source dir actually exists
if storage.exists(path):

View File

@ -308,7 +308,7 @@ class ManifestFilesMixin(HashedFilesMixin):
except ValueError:
pass
else:
version = stored.get('version', None)
version = stored.get('version')
if version == '1.0':
return stored.get('paths', OrderedDict())
raise ValueError("Couldn't load manifest '%s' (version %s)" %
@ -341,7 +341,7 @@ class _MappingCache(object):
self.cache.set(key, value)
def __getitem__(self, key):
value = self.cache.get(key, None)
value = self.cache.get(key)
if value is None:
raise KeyError("Couldn't find a file name '%s'" % key)
return value

View File

@ -74,7 +74,7 @@ class BaseCache(object):
self.key_prefix = params.get('KEY_PREFIX', '')
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):
"""

View File

@ -24,7 +24,7 @@ class BaseMemcachedCache(BaseCache):
self.LibraryValueNotFoundException = value_not_found_exception
self._lib = library
self._options = params.get('OPTIONS', None)
self._options = params.get('OPTIONS')
@property
def _cache(self):

View File

@ -32,7 +32,7 @@ class Command(BaseCommand):
else:
app_configs = None
tags = options.get('tags', None)
tags = options.get('tags')
if tags:
try:
invalid_tag = next(

View File

@ -43,7 +43,7 @@ class Command(BaseCommand):
self.dry_run = options.get('dry_run', False)
self.merge = options.get('merge', 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)
# Make sure the app they asked for exists
@ -165,7 +165,7 @@ class Command(BaseCommand):
if not self.dry_run:
# Write the migrations file to the disk.
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):
os.mkdir(migrations_directory)
init_path = os.path.join(migrations_directory, "__init__.py")

View File

@ -23,8 +23,8 @@ class Serializer(base.Serializer):
"""
def indent(self, level):
if self.options.get('indent', None) is not None:
self.xml.ignorableWhitespace('\n' + ' ' * self.options.get('indent', None) * level)
if self.options.get('indent') is not None:
self.xml.ignorableWhitespace('\n' + ' ' * self.options.get('indent') * level)
def start_serialization(self):
"""

View File

@ -591,7 +591,7 @@ class MigrationAutodetector(object):
added = set(self.new_proxy_keys) - set(self.old_proxy_keys)
for app_label, model_name in sorted(added):
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
dependencies = [
(app_label, model_name, None, False),
@ -695,7 +695,7 @@ class MigrationAutodetector(object):
for name, field in sorted(related_fields.items()):
dependencies.append((app_label, model_name, name, False))
# 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:
dependencies.append((through_user[0], through_user[1], through_user[2], False))
# 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)
for app_label, model_name in sorted(deleted):
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(
app_label,
operations.DeleteModel(
@ -980,12 +980,12 @@ class MigrationAutodetector(object):
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]
new_model_state = self.to_state.models[app_label, model_name]
if (old_model_state.options.get("order_with_respect_to", None) !=
new_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")):
# Make sure it comes second if we're adding
# (removal dependency is part of RemoveField)
dependencies = []
if new_model_state.options.get("order_with_respect_to", None):
if new_model_state.options.get("order_with_respect_to"):
dependencies.append((
app_label,
model_name,
@ -997,7 +997,7 @@ class MigrationAutodetector(object):
app_label,
operations.AlterOrderWithRespectTo(
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,
)

View File

@ -1739,7 +1739,7 @@ class FilePathField(Field):
kwargs['allow_files'] = self.allow_files
if self.allow_folders is not False:
kwargs['allow_folders'] = self.allow_folders
if kwargs.get("max_length", None) == 100:
if kwargs.get("max_length") == 100:
del kwargs["max_length"]
return name, path, args, kwargs
@ -1955,7 +1955,7 @@ class GenericIPAddressField(Field):
kwargs['unpack_ipv4'] = self.unpack_ipv4
if self.protocol != "both":
kwargs['protocol'] = self.protocol
if kwargs.get("max_length", None) == 39:
if kwargs.get("max_length") == 39:
del kwargs['max_length']
return name, path, args, kwargs
@ -2099,7 +2099,7 @@ class SlugField(CharField):
def deconstruct(self):
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']
if self.db_index is False:
kwargs['db_index'] = False
@ -2288,7 +2288,7 @@ class URLField(CharField):
def deconstruct(self):
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']
return name, path, args, kwargs

View File

@ -282,7 +282,7 @@ class FileField(Field):
def deconstruct(self):
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"]
kwargs['upload_to'] = self.upload_to
if self.storage is not default_storage:

View File

@ -1216,7 +1216,7 @@ class RawQuerySet(object):
model_cls = deferred_class_factory(self.model, skip)
else:
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([
f.get_col(f.model._meta.db_table) if f else None for f in fields
])

View File

@ -378,7 +378,7 @@ class BaseModelForm(BaseForm):
# from validation.
else:
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:
exclude.append(f.name)
return exclude

View File

@ -50,7 +50,7 @@ class Media(object):
self._js = []
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):
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
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_):
"""
@ -317,7 +317,7 @@ class MultipleHiddenInput(HiddenInput):
if value is None:
value = []
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
id_ = final_attrs.get('id', None)
id_ = final_attrs.get('id')
inputs = []
for i, v in enumerate(value):
input_attrs = dict(value=force_text(v), **final_attrs)
@ -331,7 +331,7 @@ class MultipleHiddenInput(HiddenInput):
def value_from_datadict(self, data, files, name):
if isinstance(data, MultiValueDict):
return data.getlist(name)
return data.get(name, None)
return data.get(name)
class FileInput(Input):
@ -343,7 +343,7 @@ class FileInput(Input):
def value_from_datadict(self, data, files, name):
"File widgets take data from FILES, not POST"
return files.get(name, None)
return files.get(name)
FILE_INPUT_CONTRADICTION = object()
@ -581,13 +581,13 @@ class NullBooleanSelect(Select):
return super(NullBooleanSelect, self).render(name, value, attrs, choices)
def value_from_datadict(self, data, files, name):
value = data.get(name, None)
value = data.get(name)
return {'2': True,
True: True,
'True': True,
'3': False,
'False': False,
False: False}.get(value, None)
False: False}.get(value)
class SelectMultiple(Select):
@ -607,7 +607,7 @@ class SelectMultiple(Select):
def value_from_datadict(self, data, files, name):
if isinstance(data, MultiValueDict):
return data.getlist(name)
return data.get(name, None)
return data.get(name)
@html_safe
@ -706,7 +706,7 @@ class ChoiceFieldRenderer(object):
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`).
"""
id_ = self.attrs.get('id', None)
id_ = self.attrs.get('id')
output = []
for i, choice in enumerate(self.choices):
choice_value, choice_label = choice
@ -831,7 +831,7 @@ class MultiWidget(Widget):
value = self.decompress(value)
output = []
final_attrs = self.build_attrs(attrs)
id_ = final_attrs.get('id', None)
id_ = final_attrs.get('id')
for i, widget in enumerate(self.widgets):
try:
widget_value = value[i]
@ -1031,7 +1031,7 @@ class SelectDateWidget(Widget):
return date_value.strftime(input_format)
else:
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):
if 'id' in self.attrs:

View File

@ -172,7 +172,7 @@ class HttpRequest(object):
raise ImproperlyConfigured(
'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 self._get_scheme()

View File

@ -131,11 +131,11 @@ class FetchFromCacheMiddleware(object):
if cache_key is None:
request._cache_update_cache = True
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 response is None and request.method == 'HEAD':
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:
request._cache_update_cache = True

View File

@ -28,7 +28,7 @@ class XFrameOptionsMiddleware(object):
"""
def process_response(self, request, 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
# Don't set it if they used @xframe_options_exempt

View File

@ -1325,7 +1325,7 @@ class Library(object):
# inclusion tags are often used for forms, and we need
# instructions for using CSRF protection to be as simple
# as possible.
csrf_token = context.get('csrf_token', None)
csrf_token = context.get('csrf_token')
if csrf_token is not None:
new_context['csrf_token'] = csrf_token
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
the cached module from libraries.
"""
lib = libraries.get(library_name, None)
lib = libraries.get(library_name)
if not lib:
templatetags_modules = get_templatetags_modules()
tried_modules = []

View File

@ -53,7 +53,7 @@ class CommentNode(Node):
class CsrfTokenNode(Node):
def render(self, context):
csrf_token = context.get('csrf_token', None)
csrf_token = context.get('csrf_token')
if csrf_token:
if csrf_token == 'NOTPROVIDED':
return format_html("")

View File

@ -414,7 +414,7 @@ class Client(RequestFactory):
"""
if apps.is_installed('django.contrib.sessions'):
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:
return engine.SessionStore(cookie.value)
else:

View File

@ -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."""
ctx = hashlib.md5()
for header in headerlist:
value = request.META.get(header, None)
value = request.META.get(header)
if value is not None:
ctx.update(force_bytes(value))
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)
if cache is None:
cache = caches[settings.CACHE_MIDDLEWARE_ALIAS]
headerlist = cache.get(cache_key, None)
headerlist = cache.get(cache_key)
if headerlist is not None:
return _generate_cache_key(request, method, headerlist, key_prefix)
else:

View File

@ -18,7 +18,7 @@ def xframe_options_deny(view_func):
"""
def wrapped_view(*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'
return resp
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):
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'
return resp
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)

View File

@ -32,8 +32,8 @@ class SingleObjectMixin(ContextMixin):
queryset = self.get_queryset()
# Next, try looking up by primary key.
pk = self.kwargs.get(self.pk_url_kwarg, None)
slug = self.kwargs.get(self.slug_url_kwarg, None)
pk = self.kwargs.get(self.pk_url_kwarg)
slug = self.kwargs.get(self.slug_url_kwarg)
if pk is not None:
queryset = queryset.filter(pk=pk)

View File

@ -36,7 +36,7 @@ def set_language(request):
next = '/'
response = http.HttpResponseRedirect(next)
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):
next_trans = translate_url(next, lang_code)
if next_trans != next: