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 <[email protected]> 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 Dec 2, 2009, at 2:01 PM, jul wrote:
>
> > 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 <[email protected]> wrote:
> >> On Wed, Dec 2, 2009 at 1:36 PM, jul <[email protected]> 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 use a JavaScript template (there are several jQuery plugins),
> >> just return the data in JSON.
>
> >> --
> >> Javier
>
> > --
>
> > 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
> > athttp://groups.google.com/group/django-users?hl=en
> > .
--
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.