mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 00:19:53 +03:00
speed ups
Less f strings needed for non-modified strings and one indentation speedup fixed.
This commit is contained in:
parent
0b49e13ace
commit
dca1b5bc0e
|
@ -12,6 +12,7 @@ User = get_user_model()
|
|||
|
||||
class TokenChangeList(ChangeList):
|
||||
"""Map to matching User id"""
|
||||
|
||||
def url_for_result(self, result):
|
||||
pk = result.user.pk
|
||||
return reverse(f'admin:{self.opts.app_label}_{self.opts.model_name}_change',
|
||||
|
|
|
@ -296,7 +296,7 @@ class OrderingFilter(BaseFilterBackend):
|
|||
for key, label in self.get_valid_fields(queryset, view, context):
|
||||
options.append((key, f'{label} - {_("ascending")}'))
|
||||
options.append(('-' + key, f'{label} - {_("descending")}'))
|
||||
context['options'] = options
|
||||
context['options'] = options
|
||||
return context
|
||||
|
||||
def to_html(self, request, queryset, view):
|
||||
|
|
|
@ -411,9 +411,9 @@ class HyperlinkedRelatedField(RelatedField):
|
|||
if value in ('', None):
|
||||
value_string = {'': 'the empty string', None: 'None'}[value]
|
||||
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"entries in your URL conf."
|
||||
"entries in your URL conf."
|
||||
)
|
||||
raise ImproperlyConfigured(msg % self.view_name)
|
||||
|
||||
|
|
|
@ -1114,7 +1114,7 @@ class ModelSerializer(Serializer):
|
|||
)
|
||||
|
||||
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__}."
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user