Opened 11 years ago
Closed 11 years ago
#21951 closed Cleanup/optimization (fixed)
Docs should assume Python 3 first for __str__/__unicode__ methods
Reported by: | Tim Graham | Owned by: | alasdair |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
def __unicode__
should be replaced with def __str__
and # On Python 3: def __str__(self):
should be replaced with # On Python 2: def __unicode__(self):
Change History (5)
comment:1 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 11 years ago
comment:3 by , 11 years ago
- You could repeat the method twice: first the Python 3 version, then the Python 2 version.
- I agree.
comment:4 by , 11 years ago
- You could repeat the method twice: first the Python 3 version, then the Python 2 version.
Thanks for the suggestion. I've updated my patch to include examples for Python 3 and 2.
Pull request https://github.com/django/django/pull/2258
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
I have done most of this ticket in a branch
https://github.com/alasdairnicol/django/compare/ticket_21951
I'm unsure what to do about the following docs pages
__str__
method is written for python 2, and returns bytes__str__
with__unicode__
. The page is historic, I suggest leaving it as it is.