Re: Serialization

2009-02-04 Thread Russell Keith-Magee

On Thu, Feb 5, 2009 at 8:35 AM, issya  wrote:
>
> My ideal situation would be to initially load the data through ajax
> and update through ajax. But I cannot find an easy way to do this. If
> I searialize the data, I don't see an easy way to deserialize it.

Are you aware of the following:

http://docs.djangoproject.com/en/dev/topics/serialization/

?

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Serialization

2009-02-04 Thread issya

Thanks for the reply. I was aware of that but I guess I don't
understand how to go about using it. I do understand that I can
serialize a queryset. But I cannot just go and use the serialized data
as template context. From the options I've seen, it looks like if I
did something like that I would have to process everything with the
javascript including iterating through the data and making an html
layout. I may be confused though, little sleep and a lack of knowledge
will do that.

I was just trying to check to see if you could maybe deserialize it
with a custom template tag or some other easy thing.

On Feb 4, 10:45 pm, Russell Keith-Magee 
wrote:
> On Thu, Feb 5, 2009 at 8:35 AM,issya wrote:
>
> > My ideal situation would be to initially load the data through ajax
> > and update through ajax. But I cannot find an easy way to do this. If
> > I searialize the data, I don't see an easy way to deserialize it.
>
> Are you aware of the following:
>
> http://docs.djangoproject.com/en/dev/topics/serialization/
>
> ?
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Serialization

2009-02-04 Thread Brian Neal

Hi -

I'm working on a very similar problem (displaying data on a Google
map). I haven't totally implemented this yet, but my way forward is to
use AJAX to request the map data from my Django application, which
will serve it as JSON (by serializing it). You then "deserialize" it
in the Javascript code, turning it into a Javascript datastructure on
the client side. If you are using jQuery for example, jQuery will
deserialize it for you. If you are writing the Javascript by hand, you
deserialize it by doing an "eval" on the received data.

BN

On Feb 4, 10:09 pm, issya  wrote:
> Thanks for the reply. I was aware of that but I guess I don't
> understand how to go about using it. I do understand that I can
> serialize a queryset. But I cannot just go and use the serialized data
> as template context. From the options I've seen, it looks like if I
> did something like that I would have to process everything with the
> javascript including iterating through the data and making an html
> layout. I may be confused though, little sleep and a lack of knowledge
> will do that.
>
> I was just trying to check to see if you could maybe deserialize it
> with a custom template tag or some other easy thing.
>
> On Feb 4, 10:45 pm, Russell Keith-Magee 
> wrote:
>
> > On Thu, Feb 5, 2009 at 8:35 AM,issya wrote:
>
> > > My ideal situation would be to initially load the data through ajax
> > > and update through ajax. But I cannot find an easy way to do this. If
> > > I searialize the data, I don't see an easy way to deserialize it.
>
> > Are you aware of the following:
>
> >http://docs.djangoproject.com/en/dev/topics/serialization/
>
> > ?
>
> > Yours,
> > Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Serialization

2009-02-04 Thread Russell Keith-Magee

On Thu, Feb 5, 2009 at 1:09 PM, issya  wrote:
>
> Thanks for the reply. I was aware of that but I guess I don't
> understand how to go about using it. I do understand that I can
> serialize a queryset. But I cannot just go and use the serialized data
> as template context. From the options I've seen, it looks like if I
> did something like that I would have to process everything with the
> javascript including iterating through the data and making an html
> layout. I may be confused though, little sleep and a lack of knowledge
> will do that.

There is no need for templates to be involved at all. Django's
serializers will turn a queryset into a serialized string. That string
can be provided literally as the content for a HttpResponse (just
remember to set the content type for the response to suit the
serialization format). You don't need to go through a template
rendering process on top of this.

What you then do on the client side is entirely up to you - jQuery
provides some nice deserialization methods for AJAX requests, but
there are many other options.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Serialization

2009-02-04 Thread issya

Thanks for the reply Russ. I will check into different things, you
make it sound easier than it looks. :)

On Feb 4, 11:33 pm, Russell Keith-Magee 
wrote:
> On Thu, Feb 5, 2009 at 1:09 PM, issya  wrote:
>
> > Thanks for the reply. I was aware of that but I guess I don't
> > understand how to go about using it. I do understand that I can
> > serialize a queryset. But I cannot just go and use the serialized data
> > as template context. From the options I've seen, it looks like if I
> > did something like that I would have to process everything with the
> > javascript including iterating through the data and making an html
> > layout. I may be confused though, little sleep and a lack of knowledge
> > will do that.
>
> There is no need for templates to be involved at all. Django's
> serializers will turn a queryset into a serialized string. That string
> can be provided literally as the content for a HttpResponse (just
> remember to set the content type for the response to suit the
> serialization format). You don't need to go through a template
> rendering process on top of this.
>
> What you then do on the client side is entirely up to you - jQuery
> provides some nice deserialization methods for AJAX requests, but
> there are many other options.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Serialization

2009-02-04 Thread issya

Brian, I can get data on the maps with no problem. It is just making
it change when the user selects something. If you are trying to get
data on a map, I have a handy way for you to do it. This is only for
your template. You will have to find a way to geocode everything ahead
of time. GeoDjango can do this or something like GeoPy can also. There
are also snippets on Django snippets that have different ways doing
it. Sorry if you already know how to do this and I just misunderstood.
This worked for me because I already had the lat and long for what I
was doing.

# In your template do this. The gmap will load in the div with the id
of map.
# You can style the div to be different sizes. You can also get a
smaller map
# control from google.


http://maps.google.com/maps?
file=api&v=2&key=GOOGLE KEY GOES HERE!"