mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #20224 -- Update docs examples which mention __unicode__
Thanks Marc Tamlyn and Tim Graham for the review.
This commit is contained in:
@@ -446,12 +446,14 @@ Atom1Feed
|
||||
def fancy_utility_function(s, ...):
|
||||
# Do some conversion on string 's'
|
||||
...
|
||||
# Replace unicode by str on Python 3
|
||||
fancy_utility_function = allow_lazy(fancy_utility_function, unicode)
|
||||
|
||||
The ``allow_lazy()`` decorator takes, in addition to the function to decorate,
|
||||
a number of extra arguments (``*args``) specifying the type(s) that the
|
||||
original function can return. Usually, it's enough to include ``unicode`` here
|
||||
and ensure that your function returns only Unicode strings.
|
||||
original function can return. Usually, it's enough to include ``unicode``
|
||||
(or ``str`` on Python 3) here and ensure that your function returns only
|
||||
Unicode strings.
|
||||
|
||||
Using this decorator means you can write your function and assume that the
|
||||
input is a proper string, then add support for lazy translation objects at the
|
||||
|
||||
Reference in New Issue
Block a user