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实现哦

  • 相关阅读:
    ssh.sh_for_ubuntu1604
    ssh.sh_for_ubuntu1404
    ssh.sh_for_ubuntu1204
    ssh.sh_for_centos
    raw,cow,qcow,qcow2镜像的比较
    Oz 创建Windows2008R2镜像
    Oz 创建Ubuntu镜像
    Oz 创建Debian8镜像
    Oz 创建CentOS7镜像
    Oz 创建CentOS6镜像
  • 原文地址:https://www.cnblogs.com/lgh344902118/p/7052625.html
Copyright © 2011-2022 走看看