klipstein/dojango — Issue #41: 41 - dojango datagrid fails in Django 1.2 because new field "_state" of type <django.db.models.base.ModelState> is not JSON serializable 
Author: klipstein
Created: 2011-11-06 12:58:10+00:00
State: open

What steps will reproduce the problem?
Normal usage of datagrid fails when trying to use Django 1.2 Beta

What is the expected output? What do you see instead?
The grid appears on the form without any data, instead this message:
"Sorry, an error occurred"

Using the django testserver, this output is shown:
"===============Exception=============
<django.db.models.base.ModelState object at 0xa717dec> is not JSON serializable

{'numRows': 80, 'items': [{'init_type': None, 'clone_id': 2962L, '_state':
<django.db.models.base.ModelState object at 0xa717dec>,
..."

What version of the product are you using?
dojango 0.4.6, django 1.4.1
On what operating system?
ubuntu 9.10

Please provide any additional information below.
After some investigation, and hacking I could bypass this problem by
changing the dojango/views.py
and force it to omit the "_state" field from the data.
If a foreign key is in the model, then the foreign key object can not be in
the field list, because it also contains a "_state" field.

But my hack just proofs the point that is stated in the summary of this issue:
dojango datagrid fails in Django 1.2 because new field "_state" of type
<django.db.models.base.ModelState> is not JSON serializable
It needs a proper fix.

I attach the hacked views.py

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