speed ups

Less f strings needed for non-modified strings and one indentation speedup fixed.
This commit is contained in:
Jeremy Langley 2022-02-20 08:48:26 -08:00
parent 0b49e13ace
commit dca1b5bc0e
4 changed files with 5 additions and 4 deletions

View File

@ -12,6 +12,7 @@ User = get_user_model()
class TokenChangeList(ChangeList): class TokenChangeList(ChangeList):
"""Map to matching User id""" """Map to matching User id"""
def url_for_result(self, result): def url_for_result(self, result):
pk = result.user.pk pk = result.user.pk
return reverse(f'admin:{self.opts.app_label}_{self.opts.model_name}_change', return reverse(f'admin:{self.opts.app_label}_{self.opts.model_name}_change',

View File

@ -296,7 +296,7 @@ class OrderingFilter(BaseFilterBackend):
for key, label in self.get_valid_fields(queryset, view, context): for key, label in self.get_valid_fields(queryset, view, context):
options.append((key, f'{label} - {_("ascending")}')) options.append((key, f'{label} - {_("ascending")}'))
options.append(('-' + key, f'{label} - {_("descending")}')) options.append(('-' + key, f'{label} - {_("descending")}'))
context['options'] = options context['options'] = options
return context return context
def to_html(self, request, queryset, view): def to_html(self, request, queryset, view):

View File

@ -411,9 +411,9 @@ class HyperlinkedRelatedField(RelatedField):
if value in ('', None): if value in ('', None):
value_string = {'': 'the empty string', None: 'None'}[value] value_string = {'': 'the empty string', None: 'None'}[value]
msg += ( msg += (
f" WARNING: The value of the field on the model instance " " WARNING: The value of the field on the model instance "
f"was {value_string}, which may be why it didn't match any " f"was {value_string}, which may be why it didn't match any "
f"entries in your URL conf." "entries in your URL conf."
) )
raise ImproperlyConfigured(msg % self.view_name) raise ImproperlyConfigured(msg % self.view_name)

View File

@ -1114,7 +1114,7 @@ class ModelSerializer(Serializer):
) )
assert not (fields and exclude), ( assert not (fields and exclude), (
f"Cannot set both 'fields' and 'exclude' options on " "Cannot set both 'fields' and 'exclude' options on "
f"serializer {self.__class__.__name__}." f"serializer {self.__class__.__name__}."
) )