System Message within Tutorial 1: Why __unicode__() and not __str__()
|Reported by:||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)
comment:1 Changed 9 years ago by
|Owner:||changed from Jacob to anonymous|
|Patch needs improvement:||unset|
|Status:||new → assigned|
|Triage Stage:||Unreviewed → Ready for checkin|