klipstein/dojango — Issue #44: 44 - datagrid fails on models with a imagefield. 
Author: klipstein
Created: 2011-11-06 12:58:50+00:00
State: open

What steps will reproduce the problem?
1. Create a model with a ImageField
2. Create a datagrid of that model
3. The view the datagrid loads to get the data will fail with messages like :
<ImageFieldFile: None> is not JSON serializable

What is the expected output? What do you see instead?
Expected json output for the dojo.data api to populate the grid.

What version of the product are you using? On what operating system?
Dojango 0.4.6, Dojo 1.4.2, Django 1.1.1-1ubuntu1 (ubuntu karmic package).
Running with local development server.

Please provide any additional information below.
Logs from the development server:
===============Exception=============

<ImageFieldFile: None> is not JSON serializable

{'numRows': 1, 'items': [{'status': u'O', 'model_id': 1L,
'vehicle_category_id': 2L, 'number_of_doors': 4L, 'key_name':
u'testkeyname', 'transmission_type': u'A', 'image': <ImageFieldFile: None>,
'year': 345L, 'id': 1L, 'registration_number': u'TestRegNumber'}],
'identifier': 'id', 'success': True}

This is an issue even if the list_display is set and does not include the
image field, since the image field still gets added into the 'complete'
array which is then serialized into json.

I have attached a patch which fixes this by not including image fields in
the items, but this will only help for models where there is a image field
but we don't need it included on the grid.

I'm quite new to django and dojango and fairly new to dojo, so hopefully
this is right.

Original link: http://code.google.com/p/dojango/issues/detail?id=44