#19965 closed Bug (fixed)
Problem with __unicode__ in your tutorial
Reported by: | 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)
Change History (9)
by , 12 years ago
Attachment: | pollobjects.jpg added |
---|
by , 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 , 12 years ago
Attachment: | partoftutorial.jpg added |
---|
The part of your tutorial I'm talking about. Page 1.
comment:1 by , 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:3 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 12 years ago
Component: | Uncategorized → Documentation |
---|---|
Easy pickings: | set |
Has patch: | set |
Triage Stage: | Accepted → Ready for checkin |
The real patch is here: https://github.com/itsallvoodoo/django/commit/71a7b43de885caf0ecf5d31d5f39a6b0b08f7615
It looks good to me.
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.