I have a rather weird question:
So, I have a simple dictionary in python, looking like so:
data={'Acoustics': {'Product Type': 'Acoustic Pod', 'Width [cm]': '1000', 'Noise Reduction Coefficient': '29 dB', 'Standards, Certification, and Documentation': 'PN EN-ISO 717-1:1999 ; EN 13501 B, s1, d0', 'Material': 'MDF ; Glass ; Acoustic composite', 'Color': 'NCS ; RAL', 'Installation Method': 'Own assembly ; Installation by the manufacturer', 'Facing Material': 'MDF ; Certified Paint', 'Type': 'Adjustable Ventilation ; Motion Sensor ; LED 6000K 2W ; 230V ; RJ45 or USB Charger ; Integrated seat and shelf'}}
and I try to save this via django onto my pgSQL database (with jsonb column), and I somehow end up with (notice the double quote at the start and end):
"{'Acoustics': {'Product Type': 'Acoustic Pod', 'Width [cm]': '1000', 'Noise Reduction Coefficient': '29 dB', 'Standards, Certification, and Documentation': 'PN EN-ISO 717-1:1999 ; EN 13501 B, s1, d0', 'Material': 'MDF ; Glass ; Acoustic composite', 'Color': 'NCS ; RAL', 'Installation Method': 'Own assembly ; Installation by the manufacturer', 'Facing Material': 'MDF ; Certified Paint', 'Type': 'Adjustable Ventilation ; Motion Sensor ; LED 6000K 2W ; 230V ; RJ45 or USB Charger ; Integrated seat and shelf'}}"
To add to my DB, I use django forms like so:
form_data={"cvar": data}
form = myform(form_data)
if form.is_valid():
form.save()
So, now, I have two questions:
[1] How do I avoid the above scenario? Why is it getting quoted
? I simply pass a form data to save and it somehow ends up as a string rather than json.
[2] If I have such quoted json (which unfortunately I do now), how do I unquote and access this as a json (at the moment it is a damn string!).
Thank you.