zoukankan      html  css  js  c++  java
  • django验证码django-simple-captha

    搭建网站很经常要用到验证码,django中就有这样的中间件django-simple-captha

    githup地址https://github.com/mbi/django-simple-captcha.git

    下载完之后,切换到下载的目录下pip install django-simple-captcha安装

    如何使用

    一在setting中install_app中添加captcha

    二运行python manage.py makemigrations captcha,python manage.py migrate captcha

    三在urls中添加

    url(r'^captcha/', include('captcha.urls')),

    在form中添加一个CaptchaField

    from django import forms
    from captcha.fields import CaptchaField
    
    class CaptchaTestForm(forms.Form):
        myfield = AnyOtherField()
        captcha = CaptchaField()

    到时候验证form的时候如果验证码不正确会提示不合法

    四在html添加captcha

    <form action='.' method='POST'>
        {{ form.captcha }}
        <input type="submit" />
        <button class='js-captcha-refresh'></button>
    </form>

    注意点击更改验证码要自己写js实现哦

  • 相关阅读:
    os模块
    sys模块
    psutil模块
    subprocess模块
    time模块
    argparse模块
    tcp端口扫描(python多线程)
    基于http的软件仓库
    SRE思想
    redis哨兵模式
  • 原文地址:https://www.cnblogs.com/lgh344902118/p/7052625.html
Copyright © 2011-2022 走看看