我阅读了这个 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>
库需要这些来实际显示警报。如果不存在,则不会引发任何后端错误
添加回答
举报
0/150
提交
取消