Unsupported operation error creating and saving json file
Ive been trying to save a json file created from a to a filefield, I got an unsuported operation error "not readable", this is my code
from django.core.files.base import File
@receiver(post_save,sender=ProyArq)
def ifc_a_json(sender,instance,*args,**kwargs):
if instance.arch_ifc:
jsoon = ifc_2_json("path_to_file")
json_file_nom = instance.nombre.replace(' ','')+'.json'
with open(json_file_nom, 'w') as outfile:
json.dump(jsoon, outfile, indent=2)
json_fk = JsonIFC.objects.create(proy_fk=instance)
json_fk.ifc_json.save(json_file_nom,File(outfile),True)
im working with IFC files, and I want to store them also as json, I tried instead of saving the json as a JSONField, to save it as a foreign key file since the size of the json Im working are above 10mb, is this the best approach for this??
I solved the error, I needed to change the file open from "w" to "a+", which allows reading and writing