execute python through ajax

41 views
Skip to first unread message

Florian Hoedt

unread,
Mar 9, 2016, 9:22:37 AM3/9/16
to Django users
Hello Django users,
I would like to execute some python code by JS. For example if somebody clicks on a openlayers map it should execute a python based query and get the result as JSON to render it on the map.
How would I achieve something like this?

I am trying to understand the forms section of the official django tutorial without success.

Bob Gailer

unread,
Mar 9, 2016, 10:38:22 AM3/9/16
to Django users


On Mar 9, 2016 9:22 AM, "Florian Hoedt" <gann...@gmail.com> wrote:
>
> Hello Django users,
> I would like to execute some python code by JS. For example if somebody clicks on a openlayers map it should execute a python based query and get the result as JSON to render it on the map.
> How would I achieve something like this?

Google Django Ajax. There's a number of good references there.


>
> I am trying to understand the forms section of the official django tutorial without success.

This sounds like a separate issue. What's your objective and where are you stuck?

Jani Tiainen

unread,
Mar 10, 2016, 1:25:58 AM3/10/16
to django...@googlegroups.com


On 09.03.2016 15:55, Florian Hoedt wrote:
Hello Django users,
I would like to execute some python code by JS. For example if somebody clicks on a openlayers map it should execute a python based query and get the result as JSON to render it on the map.
How would I achieve something like this?

Clicking on map does have a handler that is called with coordinates you clicked on to. When handler is called you call Django view with those coordinates (ajax call maybe). Then you run your query, make response as JSON.


I am trying to understand the forms section of the official django tutorial without success.

You have to be more specific what part is unclear or what problems you have encountered.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a293a0a0-32a0-4333-aefd-d5c15e810a60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages