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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/34119ebe-e2d2-4d16-afd3-bc003d218250%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to