python - call Django view function from django HTML template -
i have simple upload function in python have put in views.py.
def upload(): global original_img,img,img2,img3,image_path,old_label_image,photo,label,image_path,image,ax,fig print "upload" image_path=tkfiledialog.askopenfilename() image = image.open(image_path) original_img= image.copy() image.thumbnail((1000,625)) photo = imagetk.photoimage(image) label = label(image=photo) label.image = photo if old_label_image not none: old_label_image.destroy() old_label_image = label label.pack()
i want function called onclick of button html template file(current.html) in django.
<button> upload pc</button>
how call view function on click of button in html? have make changes in urlconfs this? please help
in html, can use javascript's onlick way:
<input type="button" onclick="window.location.href='/upload/'"> </input>
note: "/upload/" redirects whichever view "/upload/" mapped in urls.py
edit:
please find reference below html button onclick event
Comments
Post a Comment