Instead of built-in many-to-many relationship, use some home-made one.

class Item(models.Model):
   name = models.CharField(maxlength=32)

class ItemList(models.Model):
   name = models.CharField(maxlength=32)

class ItemList_Item(models.Model):
   quantity = models.IntegerField()
   item = model.ForeignKey(Item)
   itemlist = model.ForeignKey(ItemList)

You won't be able to use the default admin widget for Many to many
selection (at least without some template ant javascript hacking), but
you'll have what you want.

Regards,
Aidas Bendoraitis [aka Archatas]


On 3/9/07, akonsu <[EMAIL PROTECTED]> wrote:
>
> hello,
>
> i suspect you cannot do this (but i can be wrong because i myself do
> not have much experience with django).
>
> you could make your own association table manually in stead of using
> ManyToManyField. of course in this case you won't have FOO_set methods
> on your models.
>
> konstantin
>
> On Mar 8, 10:04 pm, "Greg Donald" <[EMAIL PROTECTED]> wrote:
> > How can I add a field in a join table?
> >
> > I have this:
> >
> > class Item(models.Model):
> >     name = models.CharField(maxlength=32)
> >
> > class List(models.Model):
> >     name = models.CharField(maxlength=32)
> >     items = models.ManyToManyField(Item)
> >
> > which creates the 'list_items' join table fine, but then how do I put
> > a field in that same table?
> >
> > When I try to add something like this:
> >
> > class List_Items(models.Model):
> >     quantity = models.IntegerField()
> >
> > I get errors:
> >
> > _mysql_exceptions.OperationalError: (1050, "Table 'stuff_list_items'
> > already exists")
> >
> > Does Django have join models or the like?
> >
> > Thanks,
> >
> > --
> > Greg Donaldhttp://destiney.com/
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to