heya,

Ok, scratch all that, I'm an idiot.

A simple restart of my Apache process, and the m2m intermediary inline
works *grins*.

Thanks anyhow to the awesome Django community for an awesome tool =).

I do have a final question though. I can now edit "Firms" as inlines
from the "Article" page, which is good.

However, to be honest, the filter_horizontal widget was a much better
interface. I suppose there's no way to somehow use the
filter_horizontal widget within the inline, and then tack on a
"Rating" field as part of the inline?

Also, I notice that in my inline, it says "FirmRating object" right
above the select box:'

http://twitpic.com/1zo4im/full

Any way to hide/tweak that text?

Cheers,
Victor

On Jun 25, 10:09 am, Victor Hooi <victorh...@gmail.com> wrote:
> heya,
>
> Also, I should add I did try using the inlines as described in the
> docs
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-...
>
> In my admin.py, I've imported "FirmRating" at the top.
>
> I've then created an inline for it:
>
> class FirmRatingInline(admin.TabularInline):
>     model = FirmRating
>     extra = 1
>
> then used this in ArticleAdmin:
>
> class ArticleAdmin(admin.ModelAdmin):
>     #inlines = [
>     #    CategoryInline,
>     #]
>     date_hierarchy = 'publication_date'
>     filter_horizontal = ('firm', 'spokesperson')
>     list_display = ('title', 'publication_date', 'entry_date',
> 'category', 'subject', 'source_publication', 'weekly_summary')
>     list_editable = ('publication_date', 'category', 'subject',
> 'source_publication')
>     list_filter = ('publication_date', 'entry_date', 'category',
> 'subject', 'source_publication')
>     search_fields = ('title', 'publication_date', 'abstract',
> 'category__name', 'subject__name', 'source_publication__name',
> 'page_number', 'url')
>
> However, there's still no visible widget for "FirmRating" on the "Add
> Article" page.
>
> I can't tell just from the docs, but is this inline only for use on
> the main Article list page, but not on the Add Article page? Or is the
> above admin code meant to make the widget visible on the "Add Article"
> page as well?
>
> Cheers,
> Victor
>
> On Jun 25, 10:01 am, Victor Hooi <victorh...@gmail.com> wrote:
>
>
>
> > heya,
>
> > NB: This is a followup to this:
>
> >http://groups.google.com/group/django-users/browse_thread/thread/0fdc...
>
> > 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- Hide quoted text -
>
> - Show quoted text -

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