On Dec 4, 4:09 am, Eric <[EMAIL PROTECTED]> wrote: > Hello, this might be a silly question, but I'm wondering if javascript > can call a python script, and if so, how? > > To elaborate, I'm trying to customize the admin change_list page so > that editing can be done directly from the change_list, instead of > clicking into the admin change_form page. To do this, I have a > javascript that pops up a prompt box when an element in the > change_list table is clicked. I'd then like to call a python script to > modify that element in the database (since I don't believe the DB can > be modified directly in the javascript). > > If this is unnecessary or just plain wrong, or if someone has a better > way of editing items directly from the change_list, please let me > know! Thanks much for the help.
This is what AJAX is for. Get your Javascript to make a request to the server via XMLHTTPRequest, or whatever shortcuts your library of choice provides. The request should call a normal Django view which does whatever you need in the usual way, and provides a response back to the client-side Javascript either as XML, JSON or even ready- formatted HTML. So, using jQuery for example: $('.myelement').click(function() { $.post('/my-django-view/', {element: $(this).attr(id)}, function() { .... whatever actions you want the js to do on response ... } } ); -- DR --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---