Hey guys,
How do you de-serialize the object back at the ajax response.
class Cart(models.Model):
...
def get_total_quantity():
return quantity;
self.response = self.xmlhttp.responseText;
// parse the response into a JSON object
var json_data = self.response.parseJSON();
alert(json_data.get_total_quantity())
ERROR:
[Exception... "'SyntaxError: parseJSON' when calling method:
[nsIOnReadyStateChangeHandler::handleEvent]" nsresult: "0x8057001c
(NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "<unknown>" data: no]
Line 0
Best Wishes,
Kenny
On Mar 5, 3:09 pm, "Manoj Govindan" <[EMAIL PROTECTED]> wrote:
> Hi Bram,
> Here is a possible mechanism to address your second point, i.e., hide
> certain fields while serializing.
>
> Consider this model:
> class Person(models.Model):
> ... # various fields here.
>
> @staticmethod
> def fields_for_serializing():
> return [list of those field names that can be serialized]
>
> You can then invoke this method while serializing.
>
> serializers.serialize('json', Person.objects.all(), fields =
> Person.fields_for_serializing())
>
> Regards,
> Manoj
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---