[Answered ]-Using reverse (Parental)ManyToManyField in ModelAdmin

2👍

The ParentalManyToManyField needs to be defined on the parent model (which I assume is meant to be B here – i.e. the modeladmin interface is set up to edit an instance of B with several A’s linked to it) and referenced by its field name rather than the related_name. Also, it should be the parent model that’s defined as ClusterableModel, not the child:

class B(ClusterableModel):
    aes = ParentalManyToManyField('A', blank=True)

    edit_handler = TabbedInterface([
        ObjectList([
            FieldPanel('aes', widget=CheckboxSelectMultiple),
        ], heading=_('Aes')),
    ])

class A(Model):  # doesn't need to be Orderable, because M2M relations don't specify an order
    ...
👤gasman

Leave a comment