dimanche 12 avril 2015

How does a Django form convert field values to display in admin?


Vote count:

0




I have a yet another json field defined with suitable from_db_value and to_python methods, it loads and stored correctly in the database. I can save them in the database and I can return them as json to the web application.


Looking at the records from the admin, though, the record looks like:



{u'timestamp': u'2015-04-12T13:29:55Z', u'paymentstatus': u'Completed'}


which is the string representation, as computed by str, of the dict saved in the database. When I try to save the record the field tries to convert it to json and fails.


Is there a way that the field on loading gets the value from value_to_string or another method which I can customize to return a proper json dump?


(Versions: Python 2.7, Django 1.8, Postgresql: 9.4)



asked 23 secs ago







How does a Django form convert field values to display in admin?

Aucun commentaire:

Enregistrer un commentaire