Reputation: 10974
I have a symmetrical many-to-many relationship in Django
class Person(models.Model):
id = models.CharField(max_length=32, primary_key=True)
first_name = models.CharField(max_length=32)
last_name = models.CharField(max_length=32)
connections = models.ManyToManyField('self', blank=True)
How do I see the connections (i.e. myappname_person_connections) table in the admin screen (not inline but as its own table)?
e.g. in admin.py
admin.site.register(Person)
admin.site.register(???) # what to register for the connections?
Thanks
Upvotes: 1
Views: 592
Reputation: 23871
The M2M table is mapped to a model which is Person.connections.through
, so you could use
admin.site.register(Person.connections.through)
Upvotes: 2