Created
April 10, 2020 15:36
-
-
Save coci/684932ccf7a689fdd3967de016cdfdde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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