gpt4 book ai didi

python - AssertionError - 没有提供异常 - django

转载 作者:太空狗 更新时间:2023-10-29 20:37:14 25 4
gpt4 key购买 nike

我真的很困惑,不知道它想从我这里得到什么。

这是我的简单功能

def confirm_abo(request):
try:
abo = Abonnement.objects.get(id=int(request.GET.get('abocid')))
abo.status = 1
abo.save()
link = "http://127.0.0.1:8000/delete_link/?abocid=" + str(abo.id)
subject = "test subject"
message = "test message" + link
send_mail(subject, message, 'info@test.com', [abo.email], fail_silently=False)
return render(request,'abo_confirm.html',{'abo':abo,'abo_success':'yes'})
except:
return render(request,'abo_confirm.html',{'abo_success':''})#<-- problem

我进入最后一行

AssertionError at /confirm_abo/ No exception supplied

错误。

我在 django1.4 和 python 2.7 中。它一直工作到现在没有任何问题..

我做错了什么?

最佳答案

检查模板 abc_confirm.html 是否包含无效的标签用法,如下所示:

{% if x == '0' %}
...
{% else if x == '1' %} {# used `else if` instead of `elif` %}
...
{% endif %}

可能导致AssertionError ..:

>>> from django.template import Template, Context
>>>
>>> t = Template('''
... {% if x == '0' %}
... ..
... {% else if x == '1' %}
... ..
... {% endif %}
... ''')
Traceback (most recent call last):
File "<console>", line 7, in <module>
File "/home/falsetru/.virtualenvs/django14/local/lib/python2.7/site-packages/django/template/base.py", line 125, in __init__
self.nodelist = compile_string(template_string, origin)
File "/home/falsetru/.virtualenvs/django14/local/lib/python2.7/site-packages/django/template/base.py", line 153, in compile_string
return parser.parse()
File "/home/falsetru/.virtualenvs/django14/local/lib/python2.7/site-packages/django/template/base.py", line 267, in parse
compiled_result = compile_func(self, token)
File "/home/falsetru/.virtualenvs/django14/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 919, in do_if
assert token.contents == 'endif'
AssertionError

关于python - AssertionError - 没有提供异常 - django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21363285/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com