Django Admin: Many-to-Many listbox doesn't show up with a through parameter

Posted by NP on Stack Overflow See other posts from Stack Overflow or by NP
Published on 2010-05-18T03:15:15Z Indexed on 2010/05/18 3:20 UTC
Read the original article Hit count: 239

Hi All,

I have the following models:

class Message(models.Model):
    date = models.DateTimeField()
    user = models.ForeignKey(User)    
    thread = models.ForeignKey('self', blank=True, null=True)
    ...

class Forum(models.Model):
    name = models.CharField(max_length=24)
    messages = models.ManyToManyField(Message, through="Message_forum", blank=True, null=True)
    ...

class Message_forum(models.Model):
    message = models.ForeignKey(Message)
    forum = models.ForeignKey(Forum)
    status = models.IntegerField()
    position = models.IntegerField(blank=True, null=True)
    tags = models.ManyToManyField(Tag, blank=True, null=True)

In the admin site, when I go to add/change a forum, I don't see the messages listbox as you'd expect. However, it shows up if I remove the 'through' parameter in the ManyToManyField declaration. What's up with that? I've registered all three models (plus Tag) to the admin site in admin.py.

TIA

© Stack Overflow or respective owner

Related posts about django-admin

Related posts about manytomanyfield