UHH.... redirect sounds easy...... yami yami.....
Felix how does the ajax works? I am assuming is a library of javascripts?
and ajax can lunch the python code?
On Tuesday, March 10, 2015 at 1:48:56 PM UTC-5, Daniel Roseman wrote:
> On Tuesday, 10 March 2015 17:11:16 UTC, dk wrote:
>>
>> I been trying to find information on how to make a button to run a python
>> script in the back.
>> I do have a table with some buttons, and I want to click in one, and
>> behind doors, will run a python script.
>>
>> since I don't know to much javascript or flask, or php I decided to make
>> a link (later on I can make it look like a button) that link will run the
>> view witch is my script as subprocess and then
>> return back again the view of my table,
>> so basicly will click the button, will run the code, and redo the view
>> that I was all ready in. something like this.
>>
>> views:
>> def main_table(request):
>> list_of_files= here I get my files.
>> return render(request, "show_table", {"list":list_of_files})
>>
>>
>>
>> def button_do_thing(request):
>> file = request.GET.get(file_name)
>> dosomething
>>
>> main_table(request) # here is where I am actually calling again to
>> the main table to redraw it on the browswer.
>>
>> but I get the error:
>>
>> The view mes.views.test_machine didn't return an HttpResponse object. It
>> returned None instead.
>>
>> I tought passing the request should do it?
>>
>>
>> any tips, tricks? or an actual way to make the button run the script?
>>
>> thanks guys =) .
>>
>>
>
> You didn't return anything at all from your do_thing view, hence the error.
>
> However you shouldn't really call one view from the other. If you do that,
> the browser will show the URL of the main view, which will be confusing.
> Instead, after running the task, *redirect* back to the main view:
>
> from django.shortcuts import redirect
> ...
> return redirect('mes.views.main_table')
>
> --
> Daniel.
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/834b2249-ac4f-44fa-950f-1befee440a9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.