mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Replaced many smart_bytes by force_bytes
In all those occurrences, we didn't care about preserving the lazy status of the strings, but we really wanted to obtain a real bytestring.
This commit is contained in:
parent
9eafb6592e
commit
ebc773ada3
32 changed files with 74 additions and 77 deletions
|
@ -459,9 +459,9 @@ using ``__str__()`` like this::
|
|||
last_name = models.CharField(max_length=50)
|
||||
|
||||
def __str__(self):
|
||||
# Note use of django.utils.encoding.smart_bytes() here because
|
||||
# Note use of django.utils.encoding.force_bytes() here because
|
||||
# first_name and last_name will be unicode strings.
|
||||
return smart_bytes('%s %s' % (self.first_name, self.last_name))
|
||||
return force_bytes('%s %s' % (self.first_name, self.last_name))
|
||||
|
||||
``get_absolute_url``
|
||||
--------------------
|
||||
|
|
|
@ -183,7 +183,7 @@ compose a prefix, version and key into a final cache key. The default
|
|||
implementation is equivalent to the function::
|
||||
|
||||
def make_key(key, key_prefix, version):
|
||||
return ':'.join([key_prefix, str(version), smart_bytes(key)])
|
||||
return ':'.join([key_prefix, str(version), key])
|
||||
|
||||
You may use any key function you want, as long as it has the same
|
||||
argument signature.
|
||||
|
|
|
@ -227,7 +227,7 @@ If you have written a :ref:`custom password hasher <auth_password_storage>`,
|
|||
your ``encode()``, ``verify()`` or ``safe_summary()`` methods should accept
|
||||
Unicode parameters (``password``, ``salt`` or ``encoded``). If any of the
|
||||
hashing methods need byte strings, you can use the
|
||||
:func:`~django.utils.encoding.smart_bytes` utility to encode the strings.
|
||||
:func:`~django.utils.encoding.force_bytes` utility to encode the strings.
|
||||
|
||||
Validation of previous_page_number and next_page_number
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -864,7 +864,7 @@ key version to provide a final cache key. By default, the three parts
|
|||
are joined using colons to produce a final string::
|
||||
|
||||
def make_key(key, key_prefix, version):
|
||||
return ':'.join([key_prefix, str(version), smart_bytes(key)])
|
||||
return ':'.join([key_prefix, str(version), key])
|
||||
|
||||
If you want to combine the parts in different ways, or apply other
|
||||
processing to the final key (e.g., taking a hash digest of the key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue