- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我真的很困惑,不知道它想从我这里得到什么。
这是我的简单功能
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/
我在一个Spring Boot应用程序中有以下路线。并进行以下测试。第二个测试的目的是验证如果将消息“{}”发送到DIRECT:LOG终结点,它将超出To(Bean-validator://check
这是我的简单 test.py 脚本: import argparse parser = argparse.ArgumentParser('A long string that goes on and
我在Android Studio的另一台计算机上打开我的Kotlin项目,并在事件日志中遇到错误: AssertionError: Root package must be initialized R
我在redux (redux@3.7.2) 中使用combineReducer 方法时遇到错误。当我只使用一个 reducer 时,相同的代码将起作用。 Running code here 代码 co
我目前正在对我的 Controller 的一个方法进行单元测试。只是尝试测试该方法是否返回正确的字符串。 @RequestMapping(value = "/createTestscenario",
我收到错误: java.lang.AssertionError: expected: learning.java.advancedoop2.MyComplex but was: learning.ja
这个问题在这里已经有了答案: How can I check if two ArrayList differ, I don't care what's changed (6 个答案) 关闭 7 年前
我正在准备 OCP 7,我在其中一本证书书上遇到了这篇文章。 To discourage you from trying to substitute an assertion for an excep
我有一个 index.js 文件,它实现了一个 forEach 助手,如下所示: var images = [ { height: 10, width: 30 }, { height: 20,
作为实验,我 try catch 失败的断言。 try: assert 1==2 except Exception as e: print e 为什么没有显示? 最佳答案 >>> try: asser
我在 django 中创建了一个调用函数的命令。该函数执行 django orm 调用: def get_notes(): notes = Note.objects.filter(number
我有一个用户类和一个主题类。用户类可以创建一个主题,将一个主题添加到主题的字典中,并且应该能够返回主题的字典。我是 python 的新手,所以我在 python 逻辑/语法方面遇到了问题 class
我正在尝试创建一个基于用户身份验证限制结果的 View 。出于某种原因,列表切片总是导致 AssertionError Cannot filter a query once a slice has b
我正在使用带有注释处理器的内部 sun API (com.sun.tools.javac) 修改现有类。我能够使用以下代码生成 MethodDecl 并将其添加到 ClassDecl: JCTree.
这是原代码 //@author Brian Goetz and Tim Peierls @ThreadSafe public class SafePoint { @GuardedBy("thi
我能够访问 PasswordChangeSerializer 的 validate() 函数的 user_queryset,但是我仍然收到此错误: assert value is not None,
我正在尝试从破解编码面试中回答以下问题。下面的代码是 GitHub 上一个项目的一部分,here . Given a binary search tree, design an algorithm w
我正在使用 IBM Bluemix 为学校项目创建 Web 服务。 我设置了本地主机来运行我的代码,但是当我在 Windows 10 命令提示符中键入“npm start”时,我遇到了“assert.
将 tf.Dataset 传递到 tf.Keras 模型的 fit() 时,我收到 AssertionError方法。 我正在使用tensorflow==2.0.0。 我检查了我的数据集是否有效: #
我有一个异步回调,我为此编写了一个 junit 测试用例。我正在遵循 CountDownLatch 方法。如果回调失败,我必须使测试用例失败。这是我的代码 lock = new CountDo
我是一名优秀的程序员,十分优秀!