Errr, have you read this:
https://docs.djangoproject.com/en/1.4/howto/outputting-csv/

Your view can know if a form was submitted, submitted but with invalid
data and submitted with valid data. A view is just a python function
so if you have determined that the user submitted valid data, just go
ahead and extract the CSV to be output.
Perhaps you should go through the examples in the django forms
documentation again:
https://docs.djangoproject.com/en/1.4/topics/forms/?from=olddocs

However, I don't think its possible to send both an html page and a
CSV so I guess you'll have to choose one or send them one at a time
(html page then csv). I'm sure Mevlyn will know if its possible
though.

On 7/7/12, Smaran Harihar <smaran.hari...@gmail.com> wrote:
> Thanks for the reply Melvyn and Babatunde. So my script is, using the
> parameters, to search in a database and then spitting out the output back
> as CSV.
> I wish to return the CSV and also display the output in the table on my
> html template.
> Ok, so adding it to view makes more sense, but how do i connect or execute
> that view, on the click of the submit button??
> On Jul 7, 2012 1:42 AM, "Melvyn Sopacua" <m.r.sopa...@gmail.com> wrote:
>
>> On 7-7-2012 0:20, Smaran Harihar wrote:
>>
>> > I am trying to execute a python script on submit button on a html file.
>> >
>> > So i have created a view which renders a html template file and on
>> > 'submit', I wish to send few parameters to the py script.
>> >
>> > I wanted to know,
>> >
>> > 1. where should I keep my py script?
>>
>> Anywhere you want. It's probably best you describe what your script
>> does. We don't really understand why you want to execute a script and
>> not just put that code in a view function.
>> Other than that, a python script you want to execute is no different
>> than a sh script or binary command, so you'll need to use python's
>> subprocess or os module functions, pass arguments in proper shell syntax
>> and read output.
>> --
>> Melvyn Sopacua
>>
>>
>> --
>> 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.
>>
>>
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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.

Reply via email to