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 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件