Friday, July 6, 2012

[fixed] How to load initial data to you django app model

If you need to have some data in you django app when you distribute it to someone else you need to do following steps.
Suppose you have app named weather and a model in that app called City
  1. Create folder fixtures in weather directory
  2. run following comand form project main directory:
python dumpdata weather.City > "weather\fixtures\initial_data.json"
  1. Whats all
Next time you run:
python syncdb
you data will be loaded to you app model
Lean more about initial data on django official page 

No comments:

Post a Comment