Skip to content

Instantly share code, notes, and snippets.

@coci
Created April 10, 2020 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coci/684932ccf7a689fdd3967de016cdfdde to your computer and use it in GitHub Desktop.
Save coci/684932ccf7a689fdd3967de016cdfdde to your computer and use it in GitHub Desktop.
to create initial data for models in django :
1- create "fixtures" dir inside app
2- add fx.json file init
3- add data like :
[
{
"model": "activity.Todo",
"pk": 1,
"fields": {
"name": "buy food"
}
},
{
"model": "activity.Todo",
"pk": 2,
"fields": {
"name": "make call to john"
}
},
]
4 - save file
5- run command : python3 manage.py loaddata fx.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment