Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19965 closed Bug (fixed)

Problem with __unicode__ in your tutorial

Reported by: petergoldsborough@… Owned by: nobody
Component: Documentation Version: 1.5
Severity: Normal Keywords: unicode, tutorial, python 3.2
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Hi,

After having awaited Django 1.5 for a long time, I immediately wanted to start to learn how to use it. For this, I'm using your official tutorial on djangoproject.com. Unfortunately I encountered difficulties with unicode on page 1 of your tutorial.

After having followed your instructions I had the problem that even though I incorporated the unicode function in my models.py file, Poll.objects.all() would still only show me [(Poll: Poll Object)] instead of showing my question. After spending a lot of time figuring out the problem, in the process even opening up a hole new project, I, today, more or less by accident tried out putting str instead of unicode in the function and miraculously it worked and I got [(Poll: "What's up?")] whereas with unicode I didn't.

I don't know what you can make of this as I'm not an expert (yet). I just thought I would share my discovery with you.

Kind regards and keep up the great work,

Peter Goldsborough

Attachments (3)

pollobjects.jpg (99.0 KB ) - added by petergoldsborough@… 12 years ago.
shows my command prompt. Up until the very last part (the third time I call manage.py shell) I had unicode and it didn't work, in the last part I have str and it does.
models.jpg (44.5 KB ) - added by petergoldsborough@… 12 years ago.
shows my models.py file. The Poll class has the return self.question how it worked for me. The Choice Class is how it looked before (copied from your tutorial).
partoftutorial.jpg (138.6 KB ) - added by petergoldsborough@… 12 years ago.
The part of your tutorial I'm talking about. Page 1.

Download all attachments as: .zip

Change History (9)

by petergoldsborough@…, 12 years ago

Attachment: pollobjects.jpg added

shows my command prompt. Up until the very last part (the third time I call manage.py shell) I had unicode and it didn't work, in the last part I have str and it does.

by petergoldsborough@…, 12 years ago

Attachment: models.jpg added

shows my models.py file. The Poll class has the return self.question how it worked for me. The Choice Class is how it looked before (copied from your tutorial).

by petergoldsborough@…, 12 years ago

Attachment: partoftutorial.jpg added

The part of your tutorial I'm talking about. Page 1.

comment:1 by Tim Graham, 12 years ago

Yes, this is a difference between Python 2 and 3 (already reported in #19211). That said, we may want to add a warning that the tutorial is targeted at Python 2 as I'm not sure there's anything to indicate that.

comment:2 by itsallvoodoo, 12 years ago

I have submitted a pull request, #874, that addresses this issue.

comment:3 by Jacob, 12 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Aymeric Augustin, 12 years ago

Component: UncategorizedDocumentation
Easy pickings: set
Has patch: set
Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In e1bafdbffa6e8b13db12c995eaa53508e047c83c:

Fixed #19965 - Added a warning that the tutorial is written for Python 2.

Thanks itsallvoodoo for the patch.

comment:6 by Tim Graham <timograham@…>, 12 years ago

In e5c57fe1b429b401d47ac7bf8f9056b707c5ec07:

[1.5.x] Fixed #19965 - Added a warning that the tutorial is written for Python 2.

Thanks itsallvoodoo for the patch.

Backport of e1bafdbffa from master.

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