Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#3798 closed (duplicate)

order_with_respect_to fails unless column manually added

Reported by: jon.i.austin@… Owned by: Jacob
Component: Documentation Version: master
Severity: Keywords: order_with_respect_to
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



I may be missing something, but when following the documentation for order_with_respect_to and using it in an otherwise perfectly working Polls site (tutorial), I get this exception when view admin Polls or Choice sections:

Exception Value: (1054, "Unknown column 'polls_choice._order' in 'order clause'")

tried syncdb, restarting server -- fixed it by manually adding varchar _order column to table, but is this how its supposed to work, and if so should it be mentioned in the docs, as its outside what i'd consider the normal elegant flow of working in django?



code from polls app directory -

25 class Choice(models.Model):
 26     poll = models.ForeignKey(Poll, edit_inline=models.TABULAR, num_in_admin=3)
 27     choice = models.CharField(maxlength=200, core=True)
 28     votes = models.IntegerField(core=True)
 30     class Meta:
 31         order_with_respect_to ='poll'
 33     class Admin:
 34         pass
 36     def __str__(self):
 37         return self.choice

Change History (5)

comment:1 Changed 12 years ago by jon.i.austin@…

addendum: I'm using the latest svn version

comment:2 Changed 12 years ago by mike@…

Just duplicated this error.

comment:3 Changed 12 years ago by brosner <brosner@…>

To get the field in the database using syncdb won't work. syncdb is only documented to added new applications / models to the database that have not already been created. Not database fields. If you run a reset on an application it does add the column, but this does destroy the data in the database for the application. Perhaps another issue that should be addressed is how to update an application's model of new fields. Perhaps syncdb should be doing this perhaps not?

comment:4 Changed 12 years ago by anonymous

Resolution: duplicate
Status: newclosed

ah, thats true. well, considering this is a general syncdb issue -- i.e. not just this, but as brosner stated, 'any' channge to the model that effects the db layout won't update the db with syncdb, i'm going to close this.

comment:5 Changed 12 years ago by Simon G. <dev@…>

This is something we want to look at in future (SchemaEvolution) but it's currently a hard problem and we've got plenty of other things to fix up first. However, if you do want this functionality, don't hesitate to jump in and try out the SchemaEvolution branch.

Note: See TracTickets for help on using tickets.
Back to Top