How can I store history of ManyToManyField using django-simple-history.

后端 未结 2 1602
走了就别回头了
走了就别回头了 2021-01-24 06:14

How can I store history of ManyToManyField using django-simple-history. I used HistoricalRecords with attribute m2m_filds but it is throwing error: unexpected keyword ar

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-24 06:51

    I'm macro1 on GitHub, and I guess de facto maintainer of django-simple-history.

    From your question it seems that you're just asking about general ManyToManyField support compared with other fields. The short answer is that we do not currently support it.

    ManyToManyFields actually create an in-between model that represents the relationship between the two models you're working with.

    If you want tracking on that relationship I would suggest making a 'through' model representing the relationship and passing that into the ManyToManyField constructor. You could then register that through model to have its history tracked. If you get errors like "unexpected keyword argument 'm2m_fields'" with that set up please open an issue in our tracker.

提交回复
热议问题