Thanks Josh
I got myself mixed up, your code links were very helpful to me.
TabularDynamicInlineAdmin was what I needed
Cheers
G

On 05/03/15 04:45, Josh Cartmell wrote:
Hi Graham, M2M don't appear as inlines but appear on the model itself. If you want to go with inlines then you would want Span to have a ForeignKey to Happening and Happening wouldn't reference Span at all (on the model side).

Here's a model with an M2M:
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/blog/models.py#L15
and it's admin:
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/blog/admin.py#L28

Here's an example of a inline ForeignKey:
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/galleries/models.py#L119
and it's admin:
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/galleries/admin.py#L11


On Fri, Feb 27, 2015 at 11:03 PM, Graham Oliver <[email protected] <mailto:[email protected]>> wrote:

I have a class 'Happening' with a ManyToMany relationship to 'Span' as follows

    class Happening(Page, RichText):
        spans = models.ManyToManyField(Span)

    class Span(Slugged):
        start_date = models.DateField()
        end_date = models.DateField()
        start_time = models.TimeField
        end_time = models.TimeField

    In the admin for Happening I want the Span fields to appear (I
    believe the term is 'inline')

    I did this in admin.py
    class HappeningSpanInline(DynamicInlineAdminForm):
        model = Happening.spans.through

    class HappeningAdmin(PageAdmin):
        """
        Admin class for Happenings.
        """
        inlines = [HappeningSpanInline,]
        fieldsets = happening_fieldsets

    However when I try to run the server I get this message

    django.core.exceptions.ImproperlyConfigured:
    'HappeningAdmin.inlines[0]' does not inherit from BaseModelAdmin.

    Some help would be appreciated.
    Regards g


-- You received this message because you are subscribed to the Google
    Groups "Mezzanine Users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to [email protected]
    <mailto:[email protected]>.
    For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Mezzanine 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to