System Message within Tutorial 1: Why __unicode__() and not __str__()
|Reported by:||eryost@…||Owned by:||anonymous|
|Severity:||Keywords:||tutorial1 __unicode__ __str__|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have been going through your tutorial lately and noticed a change from the use of str() to unicode() and read the new block with the text below:
Why unicode() and not str()?
If you’re familiar with Python, you might be in the habit of adding str() methods to your classes, not unicode() methods.
System Message: WARNING/2 (<string>, line 499)
Block quote ends without a blank line; unexpected unindent.
We use unicode() here because Django models deal with Unicode by default. All data stored in your database is converted to Unicode when it’s returned.
Since the System Message listed above doesn't seem to be explained, I didn't think that it was the reason for a switch from str() to unicode(), but that there was something you had meant to include that had a problem.
I'm really impressed with Django - keep up the good work!
Change History (5)
Changed 8 years ago by John Shaffer <jshaffer2112@…>
comment:1 Changed 8 years ago by John Shaffer <jshaffer2112@…>
- Has patch set
- Needs documentation unset
- Needs tests unset
- Owner changed from jacob to anonymous
- Patch needs improvement unset
- Status changed from new to assigned
- Triage Stage changed from Unreviewed to Ready for checkin
comment:2 Changed 8 years ago by gwilson
- Resolution set to fixed
- Status changed from assigned to closed