Code

Opened 5 years ago

Closed 5 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: UI/UX:

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

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

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.