Opened 16 years ago
Closed 16 years ago
#9458 closed (invalid)
Mising step after adding __unicode__ methods to models; syncdb needs to be re-run.
Reported by: | Brendan_Munnelly | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi Django-ers,
Greetings from Dublin, Ireland.
After adding the unicode() method to the Poll and Choice definitions in models.py, I called the Poll.objects.all() method again in the interpreter.
But to no effect :-(
So I:
Exited the interpreter.
Ran python manage.py syncdb
Ran python manage.py shell to restart the interpreter
Re-imported mysite.polls.models import Poll, Choice
And re-ran Poll.objects.all()
And it worked! I got the string representation and not the object.
Wey hey!
You might want to insert in your docs that syscdb needs to be re-run in order for the unicode() method to take effect.
Cheers,
Brendan Munnelly
You don't need to run syncdb again. Syncdb is just for creating tables. You do need to restart the interpreter to get the changed model definition loaded. But that is already mentioned:
"Let's jump back into the Python interactive shell by running python manage.py shell again:"
right before the example of making sure the
__unicode__
method definition worked.