Opened 18 years ago

Closed 18 years ago

Last modified 18 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: dev
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

Description

hi,

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?

thanks!

jon

code from polls app directory - models.py

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)
 29
 30     class Meta:
 31         order_with_respect_to ='poll'
 32
 33     class Admin:
 34         pass
 35
 36     def __str__(self):
 37         return self.choice


Change History (5)

comment:1 by jon.i.austin@…, 18 years ago

addendum: I'm using the latest svn version

comment:2 by mike@…, 18 years ago

Just duplicated this error.

comment:3 by brosner <brosner@…>, 18 years ago

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 by anonymous, 18 years ago

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 by Simon G. <dev@…>, 18 years ago

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