Code

Opened 14 months ago

Closed 13 months ago

Last modified 13 months 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@… 14 months 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@… 14 months 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@… 14 months ago.
The part of your tutorial I'm talking about. Page 1.

Download all attachments as: .zip

Change History (9)

Changed 14 months ago by petergoldsborough@…

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.

Changed 14 months ago by petergoldsborough@…

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).

Changed 14 months ago by petergoldsborough@…

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

comment:1 Changed 14 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 14 months ago by itsallvoodoo

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

comment:3 Changed 13 months ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 13 months ago by aaugustin

  • Component changed from Uncategorized to Documentation
  • Easy pickings set
  • Has patch set
  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 13 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In e1bafdbffa6e8b13db12c995eaa53508e047c83c:

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

Thanks itsallvoodoo for the patch.

comment:6 Changed 13 months ago by Tim Graham <timograham@…>

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.