我已经创建了一个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, “模特”:“myapp.feature”, “fields”:{ “default_feature”:“0.25” } } ]
我错过了一些明显的东西吗?我已经尝试了FIXTURE_DIRS作为灯具和灯具/相同的结果。
感谢。
答案 0 :(得分:13)
您的档案:defaults.json
您的命令行参数:default.json
仔细观察。