Django 固定装置未使用 loaddata 加载

发布于 2024-08-05 10:15:12 字数 1651 浏览 6 评论 0原文

我创建了一个 json 固定装置,并将其放在我的 myapp/fixtures/ 中。我已将 myapp/fixtures 添加到 settings.FIXTURE_DIRS。 这是我尝试加载固定装置的输出:

jeff@jeff-linux:~/myapp$ ./manage.py loaddata --verbosity=2 default.json
Loading 'default' fixtures...
[...truncated checking default paths and installed apps/fixtures...]
Checking '/home/jeff/myapp/fixtures/' for fixtures...
Trying '/home/jeff/myapp/fixtures/' for default.json fixture 'default'...
No json fixture 'default' in '/home/jeff/myapp/fixtures/'.
Trying '/home/jeff/myapp/fixtures/' for default.json.gz fixture 'default'...
No json fixture 'default' in '/home/jeff/myapp/fixtures/'.
Trying '/home/jeff/myapp/fixtures/' for default.json.zip fixture 'default'...
No json fixture 'default' in '/home/jeff/myapp/fixtures/'.
Trying '/home/jeff/myapp/fixtures/' for default.json.bz2 fixture 'default'...
No json fixture 'default' in '/home/jeff/myapp/fixtures/'.
Checking absolute path for fixtures...
Trying absolute path for default.json fixture 'default'...
No json fixture 'default' in absolute path.
Trying absolute path for default.json.gz fixture 'default'...
No json fixture 'default' in absolute path.
Trying absolute path for default.json.zip fixture 'default'...
No json fixture 'default' in absolute path.
Trying absolute path for default.json.bz2 fixture 'default'...
No json fixture 'default' in absolute path.
No fixtures found.
jeff@jeff-linux:~/myapp$ ls fixtures/
defaults.json  moneytrail.json

这是 default.json 中的内容: [ { “PK”:1, "model": "myapp.feature", “字段”:{ “default_feature”:“0.25” } } ]

我在这里遗漏了一些明显的东西吗?我已经尝试使用 FIXTURE_DIRS 作为固定装置和固定装置/相同的结果。

谢谢。

I've created a json fixture, and put it in my myapp/fixtures/. I've added myapp/fixtures to settings.FIXTURE_DIRS.
Here's the output of my attempt to load the fixture:

jeff@jeff-linux:~/myapp$ ./manage.py loaddata --verbosity=2 default.json
Loading 'default' fixtures...
[...truncated checking default paths and installed apps/fixtures...]
Checking '/home/jeff/myapp/fixtures/' for fixtures...
Trying '/home/jeff/myapp/fixtures/' for default.json fixture 'default'...
No json fixture 'default' in '/home/jeff/myapp/fixtures/'.
Trying '/home/jeff/myapp/fixtures/' for default.json.gz fixture 'default'...
No json fixture 'default' in '/home/jeff/myapp/fixtures/'.
Trying '/home/jeff/myapp/fixtures/' for default.json.zip fixture 'default'...
No json fixture 'default' in '/home/jeff/myapp/fixtures/'.
Trying '/home/jeff/myapp/fixtures/' for default.json.bz2 fixture 'default'...
No json fixture 'default' in '/home/jeff/myapp/fixtures/'.
Checking absolute path for fixtures...
Trying absolute path for default.json fixture 'default'...
No json fixture 'default' in absolute path.
Trying absolute path for default.json.gz fixture 'default'...
No json fixture 'default' in absolute path.
Trying absolute path for default.json.zip fixture 'default'...
No json fixture 'default' in absolute path.
Trying absolute path for default.json.bz2 fixture 'default'...
No json fixture 'default' in absolute path.
No fixtures found.
jeff@jeff-linux:~/myapp$ ls fixtures/
defaults.json  moneytrail.json

here's what's in default.json:
[
{
"pk": 1,
"model": "myapp.feature",
"fields": {
"default_feature": "0.25"
}
}
]

Am I missing something obvious here? I've tried the FIXTURE_DIRS as both fixtures and fixtures/ same results.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美羊羊 2024-08-12 10:15:12

您的文件:defaults.json

您的命令行参数:default.json

仔细观察。

Your file: defaults.json

Your command line argument: default.json

Look closely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文