如何使用django-simple-history存储ManyToManyField的历史记录. [英] How can I store history of ManyToManyField using django-simple-history.

查看:264
本文介绍了如何使用django-simple-history存储ManyToManyField的历史记录.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用django-simple-history存储ManyToManyField的历史记录.我使用了带有属性m2m_filds的HistoricalRecords,但抛出错误:意外的关键字参数'm2m_fields'

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 argument 'm2m_fields'

推荐答案

我是GitHub上的macro1,我想是django-simple-history的事实上的维护者.

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

从您的问题来看,您似乎只是在询问与其他字段相比的常规ManyToManyField支持.简短的答案是我们目前不支持它.

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实际上创建了一个中间模型,该模型表示您正在使用的两个模型之间的关系.

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

如果您想跟踪这种关系,建议您制作一个直通"模型表示关系并将其传递给ManyToManyField构造函数.然后,您可以通过模型进行注册,以跟踪其历史记录.如果您在设置时遇到诸如意外的关键字参数'm2m_fields'"之类的错误,请在我们的跟踪器中打开一个问题.

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.

这篇关于如何使用django-simple-history存储ManyToManyField的历史记录.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆