summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2017-04-21 19:52:26 +0200
committerClaude Paroz <claude@2xlibre.net>2017-04-27 09:10:02 +0200
commit301de774c21d055e9e5a7073e5bffdb52bc71079 (patch)
tree4c0c65fd147d528cce920cbd6a16ffa493d832ca /docs
parent8ab7ce8558792f41637d6f87f2a8a117e169dd18 (diff)
Refs #27795 -- Replaced many force_text() with str()
Thanks Tim Graham for the review.
Diffstat (limited to 'docs')
-rw-r--r--docs/howto/custom-model-fields.txt8
-rw-r--r--docs/topics/serialization.txt3
2 files changed, 5 insertions, 6 deletions
diff --git a/docs/howto/custom-model-fields.txt b/docs/howto/custom-model-fields.txt
index 54a62c50db..a64790b34c 100644
--- a/docs/howto/custom-model-fields.txt
+++ b/docs/howto/custom-model-fields.txt
@@ -706,10 +706,10 @@ smoothly:
2. Put a ``__str__()`` method on the class you're wrapping up as a field. There
are a lot of places where the default behavior of the field code is to call
- :func:`~django.utils.encoding.force_text` on the value. (In our
- examples in this document, ``value`` would be a ``Hand`` instance, not a
- ``HandField``). So if your ``__str__()`` method automatically converts to
- the string form of your Python object, you can save yourself a lot of work.
+ ``str()`` on the value. (In our examples in this document, ``value`` would
+ be a ``Hand`` instance, not a ``HandField``). So if your ``__str__()``
+ method automatically converts to the string form of your Python object, you
+ can save yourself a lot of work.
Writing a ``FileField`` subclass
================================
diff --git a/docs/topics/serialization.txt b/docs/topics/serialization.txt
index fd1c8876ec..9a1b977d98 100644
--- a/docs/topics/serialization.txt
+++ b/docs/topics/serialization.txt
@@ -256,13 +256,12 @@ For example, if you have some custom type in an object to be serialized, you'll
have to write a custom :mod:`json` encoder for it. Something like this will
work::
- from django.utils.encoding import force_text
from django.core.serializers.json import DjangoJSONEncoder
class LazyEncoder(DjangoJSONEncoder):
def default(self, obj):
if isinstance(obj, YourCustomType):
- return force_text(obj)
+ return str(obj)
return super().default(obj)
You can then pass ``cls=LazyEncoder`` to the ``serializers.serialize()``