Reputation: 403
you'll probably know that I'm a newbie in django from my question.
I want to have an html file and a python script, such that whenever the user clicks on an image on the website it redirects to the html page and runs the python script.
I am really lost in the python script that handles urls, module definitions, views, ..etc.
How can I do this?
Upvotes: 2
Views: 11526
Reputation: 3068
in your template:
<a href="/myapp/mylink">
<img src="..."/>
</a>
in your urls.py, add a new url:
url(r'^mylink/$', views.mylinkview, name='mylink'),
add a new view:
def mylinkview(request):
# ... your python code/script
return HttpResponseRedirect('## your redirect template url ##')
Upvotes: 5