Opened 11 years ago

Last modified 11 years ago

#19211 closed Cleanup/optimization

Tutorial must be updated for Python 3 — at Version 2

Reported by: adj7388@… Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords: python3 unicode str
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Luke Plant)

When using Python 3.3 and 1.5-alpha-1.

See this section of the tutorial "Why __unicode__() and not __str__()?": https://docs.djangoproject.com/en/1.5/intro/tutorial01/#playing-with-the-api

This section of the tutorial says to add __unicode__() method to your Model classes so that admin and shell display useful strings. This is correct for Python 2.x, but breaks object display under Python 3.3. __str__() should be used instead of __unicode__(). Tutorial probably needs a sidebar or other additional information for users using Python 3.x.

Change History (2)

comment:1 by Aymeric Augustin, 11 years ago

Summary: 1.5 Tutorial wrong about __unicode__() method for Python 3Tutorial must be updated for Python 3
Triage Stage: UnreviewedAccepted

At the moment Python 3 support is labeled "experimental"; it's targeted at people who know what they're doing.

It seems difficult to introduce the differences between Python 2 and Python 3 in a beginner-friendly manner.

I prefer to keep a 2.x-only tutorial for now, and switch to a 3.x-only tutorial in Django 1.7 (give or take one version). It depends on how fast the Django ecosystem supports Python 3.

comment:2 by Luke Plant, 11 years ago

Description: modified (diff)

Description fixed - you can include literal code by enclosing in backticks, as described on WikiFormatting.

Note: See TracTickets for help on using tickets.
Back to Top