Re: Returning Django objects from Ajax request

2009-12-02 Thread jul
ok I've just found it: from django.core import serializers data = serializers.serialize('json', Restaurant.objects.all()) On Dec 2, 8:26 pm, Frank DiRocco wrote: > I'm not so sure that a django question as much as it is a Python   > question... > > http://docs.python.org/library/json.html > > On

Re: Returning Django objects from Ajax request

2009-12-02 Thread Frank DiRocco
I'm not so sure that a django question as much as it is a Python question... http://docs.python.org/library/json.html On Dec 2, 2009, at 2:01 PM, jul wrote: > I'm using jQuery post: > > $.post("/getRestaurant/", location, > function(data) { > /* stuff */ > }); >

Re: Returning Django objects from Ajax request

2009-12-02 Thread jul
I'm using jQuery post: $.post("/getRestaurant/", location, function(data) { /* stuff */ }); In my view, how do I convert my Restaurant array to json? Thanks for your reply! On Dec 2, 7:52 pm, Javier Guerra wrote: > On Wed, Dec 2, 2009 at 1:36 PM, jul

Re: Returning Django objects from Ajax request

2009-12-02 Thread Javier Guerra
On Wed, Dec 2, 2009 at 1:36 PM, jul wrote: > How can I return these objects to the javascript in my template? if you're using jQuery's elm.load(url) function, you have to return an HTML fragment to replace the one already in the browser; so use a template that renders just this fragment. if you

Returning Django objects from Ajax request

2009-12-02 Thread jul
hi, I'm using jQuery to send data to a view with is supposed to return some Django objects (instances of a Restaurant model). Here's what I do 1- some javascript detect the user's location in the client side 2- the location is sent to a view which select some instances of my Restaurant model 3- th