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

  • 相关阅读:
    140704
    140703
    140702
    堆排序
    并查集
    140701
    这年暑假集训-140630
    vim for python
    hihocode 第九十二周 数论一·Miller-Rabin质数测试
    hdu 3157 Crazy Circuits 有源汇和下界的最小费用流
  • 原文地址:https://www.cnblogs.com/lgh344902118/p/7052625.html
Copyright © 2011-2022 走看看