On Sat, Oct 25, 2008 at 7:26 AM, Russell Keith-Magee <[EMAIL PROTECTED] > wrote:
> > On Fri, Oct 24, 2008 at 10:16 PM, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: > > > > OK, I have a model with a many to many relationship.. pretty > > straightforward pre-1.0 code: > > > > class SpecialEvent(models.Model): > > sponsors = models.ManyToManyField(Advertiser, related_name="event > > sponsors", null=True, blank=True) > > > > Problem is, the Powers That Be want those sponsors in a certain order. > > I thought they just showed up in the order in which they were added in > > the admin (ordered by id on their table) > > > > That does not appear to be the case. They appear to order themselves > > based on their own id. > > > > So, how can I set the order in which they appear? > > If you want reliable ordering, then you have to have something > reliable to order by. If you want reliable ordering of an m2m > relation, you will need to use a m2m-intermediate model for your m2m > relation and put an extra field on the intermediate model that can be > used as the basis for reliable ordering. > I believe Russell is right. The relational solution is to add to the intermediate table a ordering column. You need to manually handle the relation with something as a Event_Advertiser model with a foreign key to the event and other to the advertiser and django adds the autoincrement id. Sort by the id and voila! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---