您将如何在Django中的应用模板中创建按钮。我的views.py中有一个脚本:
def my_python_script(request):
if request.is_ajax:
# stuff here
else:
return HttpRequest(status=400)
但是我实际上如何将其变成按钮?是否有一些HTML或CSS我需要放在某个地方?我在应用程序中看到了有关模板目录的一些信息,但不确定要放在什么目录中以及格式如何。
答案 0 :(得分:1)
您需要执行以下操作:
<button type='button' id="my_button">Click me</button>
使用js(jquery):
$("#my_button").click(){
$.get("url_to_view",{data:"data",function(response){
// response to do something after the request
});
});