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(jso
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
Manoj Govindan wrote:
>
>
>> The serializer in trunk has a fields option, which only serializes the
>> fields supplied.
>>
>> Ex:
>> serializers.serialize('json', my_user_set, fields=('username', 'id'))
>
> This doesn't work at the moment
> http://code.djangoproject.com/ticket/3466
>
> But luc
> The serializer in trunk has a fields option, which only serializes the
> fields supplied.
>
> Ex:
> serializers.serialize('json', my_user_set, fields=('username', 'id'))
This doesn't work at the moment
http://code.djangoproject.com/ticket/3466
But luckily there is also a patch ;)
Regards,
M
On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> hey everyone,
>
>
> 1. is there any way to serialize models and remove some fields? I.e. I
> would like to serialize User for example, but I definitely don't want
> the email to be there.
>
The serializer in trunk has a fields opti
My code will seem like:
def _get_data(request, obj):
if obj.icon:
icon = '' %
(obj.get_icon_url(), obj.title)
else:
icon = '' % obj.title
authors = [x.username for x in obj.authors.all()]
return ({'id':obj.id, 'icon':icon, 'title':obj.title,
'description':o
limodou wrote:
> django also uses simplejson to dump python variable, why you want to
> avoid it? And I think using simplejson is more flexiable and simple.
Because it's more generic and I don't want to recreate what's done in
the models...
In the end I did it like this:
# MODEL --
On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> limodou wrote:
> > On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
> >> hey everyone,
> >>
> >>
> >> 1. is there any way to serialize models and remove some fields? I.e. I
> >> would like to serialize User for example,
limodou wrote:
> On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>> hey everyone,
>>
>>
>> 1. is there any way to serialize models and remove some fields? I.e. I
>> would like to serialize User for example, but I definitely don't want
>> the email to be there.
>>
>> 2. is there a way
On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> hey everyone,
>
>
> 1. is there any way to serialize models and remove some fields? I.e. I
> would like to serialize User for example, but I definitely don't want
> the email to be there.
>
> 2. is there a way to provide "custom" pa
hey everyone,
1. is there any way to serialize models and remove some fields? I.e. I
would like to serialize User for example, but I definitely don't want
the email to be there.
2. is there a way to provide "custom" parts of the serialization? For
example, when serializing a Book I would lik
11 matches
Mail list logo