- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 django-simple-captcha,它在本地运行良好。一旦部署到 Heroku,它所在的页面就会出现 500 错误(我得到的唯一日志输出是 (2017-02-11T13:26:07.367450+00:00 heroku[router]: at=info method=GET path= “/contact/”主机=fathomless-harbor-1234.herokuapp.com request_id=37555c3c-c468-40cb-a142-c7dd04519e2c fwd=“73.163.191.194”dyno=web.1连接=1ms服务=83ms状态=500字节= 386
)。
我运行了./manage.py测试验证码
并得到了三个失败的测试,所有这些都有类似的错误File“/Users/pmn/.virtualenvs/within/lib/python2.7/site-packages/django/template/loader.py”,第 43 行,在 get_template 中
引发 TemplateDoesNotExist(template_name, chain=chain)
TemplateDoesNotExist:captcha_test/image.html
我使用的是 django 1.9.6 和 django-simple-captcha 0.5.3
表单.py
from django import forms
from django.template.loader import get_template
from django.core.mail import EmailMultiAlternatives
from captcha.fields import CaptchaField
class ContactForm(forms.Form):
contact_name = forms.CharField()
contact_email = forms.EmailField()
contact_phone = forms.CharField()
content = forms.CharField(widget=forms.Textarea)
cc_me = forms.BooleanField(required=False, initial=False)
captcha = CaptchaField(required=True)
def send_email(self):
contact_name = self.data["contact_name"]
contact_phone = self.data["contact_phone"]
contact_email = self.data["contact_email"]
content = self.data["content"]
template = get_template("contact.txt")
context = {
"contact_name": contact_name,
"contact_phone": contact_phone,
"contact_email": contact_email,
"content": content,
}
content = template.render(context)
subject, from_email, to = "Inquiry", contact_email, "jason@email.com"
cc_address = contact_email if "cc_me" in self.data else None
email = EmailMultiAlternatives(
subject,
content,
from_email,
["jason@email.com"],
cc=[cc_address],
headers={"Reply-To": contact_email}
)
email.send()
def __init__(self, *args, **kwargs):
super(ContactForm, self).__init__(*args, **kwargs)
for field in self.fields:
self.fields[field].widget.attrs['class'] = 'form-control'
(请注意,如果我注释掉两个验证码行,页面将在部署时加载)
最佳答案
问题是数据库迁移尚未在 Heroku 上运行。 heroku run python manage.py makemigrations
和 heroku run python manage.py migrate
修复了它。
关于python - django-simple-captcha 破坏 Heroku 部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42176628/
在 CloudFlare Web Application Firewall您可以根据 IP 地址、国家/地区名称或 ASN 阻止、白名单、CAPTCHA 或 JavaScript Challenge
有没有人能够在不给访问者带来负担(例如 CAPTCHA)且不使用集中式垃圾邮件报告系统(例如 Akismet)的情况下成功阻止其网站上的垃圾邮件 我找到了 this & it looks promis
如何在本地网络上的测试服务器中使用Google的reCAPTCHA? 根据documentation: By default, all keys work on "localhost" (or "12
你好,我看到 facebook 在使用 recaptcha,但在他们的注册页面中,他们可以显示一个单词而不是两个,然后我注意到 repcatcha 只验证第一个单词,第二个单词充当虚拟词,问题是我们能
在所有可用的CAPTCHA形式中,哪一种是“最不易破解的”,同时又保持了人类可读性? 最佳答案 我同意托马斯的观点。验证码即将出局。但是,如果必须使用它,reCAPTCHA是使用简单API的不错的提供
检测reCaptcha v2是否未加载的最佳方法是什么?我想提醒用户何时需要使用验证码才能继续,但是无法加载。 最佳答案 您可以在请求验证码时传递回调函数 将此添加到URL: ?onload=myfu
我在网站的表单提交中使用以下安全性(不可见验证码)以防止自动提交: 生成数字x上带有固定盐的md5结果并渲染它在表单内作为隐藏字段 生成 2 个隐藏字段 a 和 b,其中 a + b = x,a 和
我在这里寻找灵感。我需要对我的网站采用某种人工验证,但目前最常见的方法(要求用户将他们在图像中看到的字母和数字输入到文本输入框中)似乎有点垃圾 - 我发现有时很难弄清楚字母和数字是什么。 一定有更好的
复选框是否提供了在网站上使用验证码的替代方法?我想我需要使用验证码进行用户注册。相反,如果我为“通过单击此处我同意......”之类的条款添加一个复选框,可以解决机器人问题吗?或者除了复选框之外还需要
我刚刚在 github 上看到了这个天才脚本: https://github.com/jsavoie/proof-of-work-login 我的问题是:为什么 POW 登录在 2018 年还不是世界
我正在尝试使用OpenCV和pytesseract解决一些简单的验证码。验证码示例包括: 我试图用一些过滤器去除嘈杂的点: import cv2 import numpy as np import p
我知道这不是一个真正的编程问题,但我不知道在哪里问。 我应该在注册表单中使用验证码吗? Facebook、twitter、foursquare、gowalla 等...不要使用其中之一(或不可见的)。
我想阻止垃圾邮件发送者使用我的网站。但我觉得验证码很烦人。我所说的不仅仅是“输入文本”类型,而是任何需要用户浪费时间来证明自己是人类的东西。 我在这里能做什么? 最佳答案 要求 Javascript
这个问题已经有答案了: 已关闭14 年前。 破解验证码的方法、算法有哪些? 最佳答案 Security Now 播客有一集是关于这个的。文字记录链接如下。 http://www.grc.com/sn/
我的网站使用 6 位数字的验证码,但是如果攻击者尝试所有组合,他很可能会成功提交表格分数的次数。(理论上是 1/百万,自从我使用随机数生成器以来,在实践中更多不是真正随机的)。 反正我有办法进一步阻止
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post的一个问题。
我有一个用户填写的网络表单,并将信息发送到服务器并存储在数据库中。我担心机器人可能只是填写表格,我最终会得到一个充满无用记录的数据库。如何防止机器人填写我的表格?我在想可能类似于 Stackoverf
reCAPTCHA的先前版本提供了制作可以在任何域上使用的全局 key 的选项。现在,在版本2中,该选项消失了,并且reCAPTCHA网站声称“V2 API中不支持全局 key ”。 我正在使用大量域
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 5年前关闭。 Improve thi
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我是一名优秀的程序员,十分优秀!