I have a model that stores Conversations as follows:
class Conversation:
sender_user = models.ForeignKey("test_app.User", on_delete=models.PROTECT,
related_name="conv_starter_user")
recipient_user = models.ForeignKey("test_app.User", on_delete=models.PROTECT,
related_name="conv_recipient_user")
It references the User model twice.
I would like to be able to go to Django Admin and see a section called 'Conversations' that would list all conversations that the user participates in, both as a starter and as a recipient. Currently, I am creating two separate inlines ConversationRecipientInline and ConversationSenderInline that I add to the User admin. This splits the Conversation view into two which is not ideal.
If you have multiple foreign keys to the same model that you want to represent as an inline in the admin, you must specify a single foreign key with the
fk_name
parameter of theInlineModelAdmin
subclass. So you can't achieve what you want withInlineModelAdmin
and your model design.