Converts .csv to Django .json seed files for use with manage.py loaddata method
- Python3.7
- Pipenv
$ git clone https://github.com/kipp-bayarea/django_db_seed.git
$ pip install pipenv
$ pipenv install
This script will take four arguments.
- --csv: The filename of the csv you want to parse
- --model: The name of the Django model you want to load this data into
- --json: A filename to save the json seed file as
- --merge: Used with the --json arg. Will merge all json files into a single file for import.
Example:
Create json seed file from csv
$ pipenv run python main.py --csv "test.csv" --model "app.test" --json "test.json"
Merge all json files for use with django's loaddata
method
$ pipenv run python main.py --merge --json "seed.json"