heya,

NB: This is a followup to this:

http://groups.google.com/group/django-users/browse_thread/thread/0fdc1dfb1fddb97b/6b559dc4abf5d4ea

but I thought I'd also ask about the model design.

To provide some background, we have a Django app that contains a list
of journal articles.

Each "Article" also has a m2m relationship to "Firm" as well as
"Spokesperson"

class Article(models.Model):
    title = models.CharField(max_length=100)
    publication_date = models.DateField()
    abstract = models.TextField() # Can we restrict this to 450
characters?
    ...fields ommited for brevity...
    firm = models.ManyToManyField(Firm, null=True, blank=True,
through='FirmRating')
    spokesperson = models.ManyToManyField(Spokeperson, null=True,
blank=True, through='SpokespersonRating')

The intermediary models, FirmRating and SpokespersonRating look like
this:

class FirmRating(models.Model):
    firm = models.ForeignKey(Firm)
    article = models.ForeignKey(Article)
    rating = models.IntegerField()

Basically, we use it to store the m2m link, as well as a "rating"
assigned to each relationship.

The issue is, as soon as I change it from a normal m2m relationship to
one with a "through" attribute, it seems to completely disappear in
the Django Admin from the "Add Article" page. Before, I had a nice
little filter_horizontal widget to create the relationships. No,
zippo...that's not a bug, is it?

Anyhow, Firstly, am I doing this the right way? Or is there another
way to create an Article, have it m2m with Firms/Spokesperson, and
assign an individual rating to each relationship?

Secondly, is there some way of making a m2m with intermediary visibile
in the admin - is it intended behaviour for it to disappear? In an
ideal world, I'd like to have the filter_horizontal, as well as an
inline widget to set the rating, all on the "Add Article" page.
However, I'm prepared to have just the filter_horizontal for the m2m,
and set the rating separately, on a separate page just for FirmRating/
SpokespersonRating (it obviously breaks the workflow a bit there).

How do people normally deal with editing m2m intermediary models in
Django?

Cheers,
Victor

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to