为了账号安全,请及时绑定邮箱和手机立即绑定

django sweetalert2 活动,当数据插入成功时

django sweetalert2 活动,当数据插入成功时

慕村225694 2022-09-29 17:48:37
我阅读了这个 https://github.com/Atrox/sweetify-django 关于sweetify的文档,我做了文档中所说的一切,但是每次用户管理员插入新数据时,sweetify都没有激活,我错过了什么吗?我已经安装了它。我正在使用詹戈 2.2.4我的网页中有这段代码{% load sweetify %}{% sweetify %}    <form method="POST" action-xhr="/InsertProduct/" enctype="multipart/form-data">    {% csrf_token %}    ....    <button type="submit" name="submit" id="submit">Submit</button></form>这是我的 views.pyimport sweetifydef InsertProduct(request):    ....    insert_data = Product(       ....    )    sweetify.success(request, 'You did it', text='Good job! You successfully showed a SweetAlert message', persistent='Hell yeah')    insert_data.save()        return redirect('/') # <-- tabbed this linesweetify.pyfrom sweetify.templatetags import sweetify    sweetify.DEFAULT_OPTS = {    'showConfirmButton': False,    'timer': 2500,    'allowOutsideClick': True,    'confirmButtonText': 'OK',}settings.pyINSTALLED_APPS = [    .....    'sweetify',]SWEETIFY_SWEETALERT_LIBRARY = 'sweetalert2'
查看完整描述

1 回答

?
元芳怎么了

TA贡献1798条经验 获得超7个赞

经过大量的努力,问题是HTML中缺少脚本:


<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9">

</script>

库需要这些来实际显示警报。如果不存在,则不会引发任何后端错误


查看完整回答
反对 回复 2022-09-29
  • 1 回答
  • 0 关注
  • 107 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号