Django,通用关系,制作装置
我正在尝试为 django-test-utils makefixture 命令添加通用关系和一对一关系支持,这里是源 http://github.com/ericholscher/django-test-utils/blob/master/test_utils/management/commands/makefixture.py< /a>
有人知道如何做到这一点吗?或者可能还有另一种工具可以实现这样的目的:
./manage.py dumpcmd User[:10] > fixtures.json
I'm trying to add generic relations and one-to-one relations support for django-test-utils makefixture command, here is the source http://github.com/ericholscher/django-test-utils/blob/master/test_utils/management/commands/makefixture.py
Does somebody have ideas how to do this? Or may be there is another tool for such thing as:
./manage.py dumpcmd User[:10] > fixtures.json
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有多种解决问题的选择。我将专注于poke-the-code方法,因为我已经有一段时间没有研究过 django 内部结构了。
我已从链接中添加了以下相关代码。请注意,我已经删除了不相关的部分。另请注意,您将要编辑的部分您的案例需要重构。
遵循以下算法,直到您满意为止。
if
语句重构为(一个或多个)单独的函数。测试。
You have several options how to approach the problem. I'll concentrate on the poke-the-code aproach, since it's been a while since I mucked around with django internals.
I have included the relevant code below from the link. Note that I have removed irrelevant parts. Also note that the part you'll be editing YOUR CASE HERE is in need of a refactor.
Follow the following algorithm until you're satisfied.
if
statements depending on the fields into (one or more) separate function(s).Test.