1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #dumpfix.py
import json
import sys
def fix_dump(in_file, out_file, model, *remove_fields):
content = json.load(open(in_file))
for item in content:
if item['model'] == model:
for field in remove_fields:
if field in item['fields']:
del item['fields'][field]
json.dump(content, open(out_file, 'w'))
if __name__ == "__main__":
"""
Usage:
python dumpfix.py olddump.json newdump.json myapp.mymodel field1 field2 ...
"""
fix_dump(*sys.argv[1:])
|
More like this
- Export models as json by aconbere 6 years, 2 months ago
- Database migration and dump/load script by akaihola 6 years, 1 month ago
- Export Django data to datestamped tarball -- choose individual models for handy packaging and archiving by fish2000 2 years, 8 months ago
- Proper fixtures loading in south data migrations by JustDelight 2 months, 3 weeks ago
- dumpdata/loaddata with MySQL and ForeignKeys by cmgreen 5 years, 4 months ago
Comments