Thanks Richard, I'll give it a go. Cheers
On May 16, 2:44 pm, "Richard Dahl" <[EMAIL PROTECTED]> wrote: > I do not think that admin currently supports this, but I could be wrong. but > here are two ways to accomplish it. > > class Item(models.Model): > name = models.CharField(max_length=30) > > class ItemOrder(models.Model): > item = models.FK(Item) > order = models.int() > > def __unicode__(self): return ('%s - %s' > %(self.item.__unicode__(), self.order)) > > class Page(models.Model): > survey = models.ForeignKey(Survey) > item = models.M2M(ItemOrder) > order = models.IntegerField() #Page Order > file_name = models.CharField(max_length=50) > > You can also add a 'unique_together' constraint to your meta class in > ItemOrder, if helpful. > hth, > -richard > > On 5/16/08, Peter Bailey <[EMAIL PROTECTED]> wrote: > > > > > I am pretty new to Django, and am building a web generating app. I am > > hoping to get a lot of functionality out of the admin. So far that is > > working great. I do have 2 classes in my models that have a many to > > many relationship. The code is generated nicely and everything works > > correctly. > > The classes represent web pages and generic items that go on pages > > such as radios, dropdowns, etc. > > > However, I would really like to add a column to the join table, > > "order", so I can use the admin of my Page class to add Items and > > define their order on that particular page. Is there a way to do this? > > I have searched around and found lots of discussions, but no solid > > answers. Sorry if this is a dumb question, but I admit I am a noob. > > Here is a code snippet: > > > # will use this for subclassing into our item subtypes > > class Item(models.Model): > > name = models.CharField(max_length=30) > > > def __unicode__(self): > > return self.name > > > class Page(models.Model): > > """Page information for survey pages - surveys will contain one or > > more of these""" > > survey = models.ForeignKey(Survey) > > items = models.ManyToManyField(Item) > > order = models.IntegerField() # this is for page ordering - not > > item ordering > > file_name = models.CharField(max_length=50) > > > def __unicode__(self): > > return self.file_name > > > class Admin: > > pass > > > class RadioBoxType(Item): > > """A Radio Button object with its specific attributes""" > > ....... > > > So, if I could somehow add an order column to the generated > > gen_pageitem table and edit it from the admin for the page, I would be > > set. I'm also not using the new admin branch which I just noticed a > > couple of days ago. Any advice on if I should switch now or later > > would be most welcome. I don't mind using newer code, but I am unsure > > of the timelines for that branch to move into the trunk etc. Don't > > want to waste time learning code that will be obsolete, but do have > > some deadlines to meet (of course). > > > Advice or pointers greatly appreciated, > > > Peter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---