シードファイルを作成
「 model 」は、「 アプリケーション名.モデル名 」の形で指定します。
pythonApp\crud\crud\fixtures\users-data.json
[
{
"model": "member.user",
"fields": {
"name": "taro",
"mail": "taro@example.com",
"gender": "False",
"age": "10",
"birthday": "2019-06-04"
}
},
{
"model": "member.user",
"fields": {
"name": "hanako",
"mail": "hanako@example.com",
"gender": "True",
"age": "20",
"birthday": "2019-06-04"
}
}
]
シードデータを登録するには、loaddata コマンドを使います。
python manage.py loaddata fixtures/users-data.json
複数の json ファイルを登録する場合は、次のようにします。
python manage.py loaddata hoge_data.json foo_data.json