weixin_33688840 2018-08-09 15:51 采纳率: 0%
浏览 77

Django按钮发送电子邮件

How would you go about creating a button in your templates of an app in Django. I have a script in my views.py:

def my_python_script(request):
    if request.is_ajax:
        # stuff here
    else:
        return HttpRequest(status=400)

But how do I actually turn this into a button? Is there some html or css I need to put somewhere? I saw some things about a templates directory in the application but I'm unsure on what things to put there and in what formats.

  • 写回答

1条回答 默认 最新

  • weixin_33728708 2018-08-09 15:57
    关注

    You would do like the following:

    <button type='button' id="my_button">Click me</button>
    

    And with a js (jquery):

    $("#my_button").click(){
         $.get("url_to_view",{data:"data",function(response){
              // response to do something after the request
         });
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于cpci总线的几个问题,有点迷糊
  • ¥15 乳腺癌数据集 相关矩阵 特征选择
  • ¥15 我的游戏账号被盗取,请问我该怎么做
  • ¥15 通关usb3.0.push文件,导致usb频繁断连
  • ¥15 有没有能解决微信公众号,只能实时拍照,没有选择相册上传功能,我不懂任何技术,,有没有给我发个软件就能搞定的方法
  • ¥15 Pythontxt文本可视化
  • ¥15 如何基于Ryu环境下使用scapy包进行数据包构造
  • ¥15 springboot国际化
  • ¥15 搭建QEMU环境运行OP-TEE出现错误
  • ¥15 Minifilter文件保护