[Fixed]-Building JSON object that can hold contents of file

1👍

You should not be creating your fixtures manually. You should populate a test database with data then use manage.py dumpdata to export it.

Django FileField and ImageField both store a path to the staticfiles location, they do not store the contents of the files directly.

If you’re trying to store the contents of a text file, that can be held in a TextField. To represent this in JSON, it will most likely need to be encoded to UTF8 to handle special characters (pretty quotes, accents, etc.) and escaped so that line endings are turned into \n, etc.

👤Soviut

Leave a comment