{ "info": { "author": "\u7801\u9f99\u54e5", "author_email": "ma_longge@sina.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Internet :: WWW/HTTP", "Topic :: Utilities" ], "description": "\u70b9\u51fb\u5012\u5b57\u9a8c\u8bc1\u7801\r\n==========================\r\n\r\n\u7b80\u4ecb\r\n--------\r\n\r\n\u70b9\u51fb\u5012\u5b57\u9a8c\u8bc1\u7801\uff0c\u4eff\u7167\u77e5\u4e4e\u9a8c\u8bc1\u7801\u6548\u679c\u5b9e\u73b0\uff0c \u7528\u6237\u901a\u8fc7\u70b9\u51fb\u9a8c\u8bc1\u7801\u4e0a\u9762\u7684\u5012\u7740\u7684\u6c49\u5b57\uff0c \u4ece\u800c\u901a\u8fc7\u9a8c\u8bc1\u7801\u9a8c\u8bc1\u3002\r\n\r\n\u73af\u5883\u6761\u4ef6\r\n------------\r\n\r\n* Python>=3.4\r\n* Django>=1.9\r\n\r\n\r\n\u5b89\u88c5\r\n----------\r\n\r\nUsing pip::\r\n\r\n $ pip install django_click_captcha\r\n\r\nor from source code::\r\n\r\n $ pip install -e git+https://github.com/malongge/click_captcha.git#egg=click_captcha\r\n\r\n\u5c06 click_captcha \u52a0\u5230 INSTALL_APPS \u5217\u8868\u5f53\u4e2d\r\n\r\n\u4f7f\u7528\u65b9\u6cd5\r\n--------\r\n\r\n\u914d\u7f6e:\r\n\r\nCLICK_CAPTCHA_WIDGET_TEMPLATE: \u9a8c\u8bc1\u7801\u6a21\u677f\u4ee3\u7801\uff0c \u9ed8\u8ba4\u4e3a `click_captcha/captcha.html`\r\n\r\nCLICK_CAPTCHA_TIMEOUT: \u9a8c\u8bc1\u7801\u8fc7\u671f\u65f6\u95f4\uff0c \u9ed8\u8ba4\u4e3a 60 \u79d2\r\n\r\nCACHE_BACKEND: \u9a8c\u8bc1\u7801\u7f13\u5b58\u670d\u52a1\uff0c \u9ed8\u8ba4\u4e3a\u6570\u636e\u5e93: `django.core.cache.backends.db.DatabaseCache`\r\n\r\n\u56e0\u6b64\u5982\u679c\u4f7f\u7528\u9ed8\u8ba4\u7684\u7f13\u5b58\u670d\u52a1\uff0c\u9700\u8981\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4 `python manage.py createcachetable` \u521b\u5efa\u7f13\u5b58\u8868\r\n\r\n\r\nurls.py \u6dfb\u52a0\u83b7\u5f97\u9a8c\u8bc1\u7801\u7684\u5730\u5740::\r\n\r\n from django.conf.urls import url\r\n\r\n from click_captcha import views\r\n\r\n urlpatterns = [\r\n url(r'click_captcha/(?P\\w+)/$', views.CaptchaView.as_view(), name='click_captcha'),\r\n ]\r\n\r\n\u52a0\u8f7d\u6837\u5f0f\u6807\u7b7e::\r\n\r\n { % load click_captcha_tags % }\r\n ...\r\n { % include_click_captcha_css False % }\r\n ...\r\n { % include_click_captcha_js False % }\r\n\r\n\r\n\u5982\u679c\u5e0c\u671b\u7528\u5b89\u88c5\u5305\u81ea\u5e26\u7684 bootstrap \u548c jquery \u53bb\u6389 False \u53c2\u6570\r\n\r\n\u6dfb\u52a0 form \u8868\u5355\uff0c \u6bd4\u5982 admin \u767b\u5f55\u914d\u7f6e::\r\n\r\n from django.contrib.admin.forms import (\r\n AdminAuthenticationForm as _AdminAuthenticationForm\r\n )\r\n from django.forms import ValidationError\r\n\r\n from click_captcha.fields import CaptchaField\r\n\r\n\r\n class AuthenticationForm(_AdminAuthenticationForm):\r\n field_order = ['captcha', 'username', 'password']\r\n\r\n captcha = CaptchaField()\r\n\r\n def _clean_fields(self):\r\n for name, field in self.fields.items():\r\n value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name))\r\n try:\r\n value = field.clean(value)\r\n self.cleaned_data[name] = value\r\n if hasattr(self, 'clean_%s' % name):\r\n value = getattr(self, 'clean_%s' % name)()\r\n self.cleaned_data[name] = value\r\n except ValidationError as e:\r\n self.add_error(name, e)\r\n return\r\n\r\n\u8fd9\u91cc _clean_fields \u662f\u60f3\u5148\u8fdb\u884c\u9a8c\u8bc1\u7801\u6821\u9a8c\uff0c \u5982\u679c\u9a8c\u8bc1\u7801\u6821\u9a8c\u4e0d\u6210\u529f\u5c31\u4e0d\u8fdb\u884c\u7528\u6237\u548c\u5bc6\u7801\u7684\u9a8c\u8bc1\u7801\u4e86\r\n\r\n\u65b0\u5efa\u4e2a sites.py, \u66ff\u6362\u539f\u6765\u7684 login form::\r\n\r\n from django.contrib.admin.sites import AdminSite as _AdminSite\r\n\r\n from apps.authentication.forms import AuthenticationForm\r\n from apps.authentication.models import User\r\n\r\n class MyAdminSite(_AdminSite):\r\n login_form = AuthenticationForm\r\n login_template = 'click_captcha/login.html'\r\n\r\n\r\n admin_site = MyAdminSite(name='myadmin')\r\n admin_site.register(User)\r\n\r\n\u5728 login.html \u4e2d\u52a0\u4e0a\u9a8c\u8bc1\u7801 form \u5b57\u6bb5::\r\n\r\n { % load click_captcha_tags %}\r\n\r\n { % block extrastyle %}\r\n { % include_click_captcha_css False %}\r\n { % endblock %}\r\n\r\n ... ...\r\n { # form \u8868\u5355\u4e0b\u63d2\u5165 #}\r\n
\r\n {{ form.captcha }}\r\n
\r\n ... ...\r\n { % block extrajs %}\r\n { % include_click_captcha_js False %}\r\n { % endblock %}\r\n\r\n\u6548\u679c\u56fe\r\n------\r\n\r\n.. image:: https://malongge.github.io/assets/django/captcha-django.gif\r\n :target: https://malongge.github.io/2017/08/04/django-zhihu-captcha-4-read.html\r\n\r\n\r\n\u5907\u6ce8\u4fe1\u606f\r\n---------\r\n\r\n\u8be5\u9879\u76ee\u4e0d\u652f\u6301 python 2 \u7248\u672c\uff0c django \u7248\u672c\u5fc5\u9700\u9ad8\u4e8e django 1.9\r\n\r\n\u8be5\u9879\u76ee\u6709\u4e00\u7cfb\u5217\u6587\u7ae0\u7684\u4ecb\u7ecd\u5176\u662f\u5982\u4f55\u5f00\u53d1\u7684\u8fc7\u7a0b\uff0c \u53ef\u4ee5\u53c2\u8003\u6587\u7ae0\u6765\u5b9a\u5236\u81ea\u5df1\u7684\u9a8c\u8bc1\u7801\r\n\r\n`\u535a\u5ba2\u5730\u5740 `_\r\n\r\n\n\n\r\n\r\nHistory\r\n-------\r\n\r\n0.1 (2017-08-18)\r\n~~~~~~~~~~~~~~~~\r\n\r\n* First release on PyPI.\r\n\n\nCredits\r\n-------\r\n\r\nDevelopment Lead\r\n~~~~~~~~~~~~~~~~\r\n\r\n* \u7801\u9f99\u54e5 - https://github.com/malongge\r\n\r\nContributors\r\n~~~~~~~~~~~~\r\n\r\n\n\nLicense\r\n-------\r\n\r\nSource code can be found at `Github `_.\r\n\r\n`The MIT License (MIT) `_::\r\n\r\n Copyright (c) 2017, \u7801\u9f99\u54e5\r\n\r\n Permission is hereby granted, free of charge, to any person obtaining a copy\r\n of this software and associated documentation files (the \"Software\"), to deal\r\n in the Software without restriction, including without limitation the rights to\r\n use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r\n the Software, and to permit persons to whom the Software is furnished to do so,\r\n subject to the following conditions:\r\n\r\n The above copyright notice and this permission notice shall be included in all\r\n copies or substantial portions of the Software.\r\n\r\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\r\n INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\r\n PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\r\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r\n OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r\n SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/malongge/click_captcha.git", "keywords": "django captcha", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django_click_captcha", "package_url": "https://pypi.org/project/django_click_captcha/", "platform": "", "project_url": "https://pypi.org/project/django_click_captcha/", "project_urls": { "Homepage": "https://github.com/malongge/click_captcha.git" }, "release_url": "https://pypi.org/project/django_click_captcha/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Django \u70b9\u51fb\u5012\u5b57\u9a8c\u8bc1\u7801", "version": "0.1.1" }, "last_serial": 3105943, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "ec00522dfafa2eb502e37a4c69253e38", "sha256": "0fba57b5b8fac04ef98231f335430c48025d837fe89d3ccef4bcd9f907846209" }, "downloads": -1, "filename": "django_click_captcha-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ec00522dfafa2eb502e37a4c69253e38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 276188, "upload_time": "2017-08-18T09:36:58", "url": "https://files.pythonhosted.org/packages/af/b2/a5ebcfdb81dc7203f8e1469740a84580eaca6c224c81be5898e51e3279a8/django_click_captcha-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ec00522dfafa2eb502e37a4c69253e38", "sha256": "0fba57b5b8fac04ef98231f335430c48025d837fe89d3ccef4bcd9f907846209" }, "downloads": -1, "filename": "django_click_captcha-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ec00522dfafa2eb502e37a4c69253e38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 276188, "upload_time": "2017-08-18T09:36:58", "url": "https://files.pythonhosted.org/packages/af/b2/a5ebcfdb81dc7203f8e1469740a84580eaca6c224c81be5898e51e3279a8/django_click_captcha-0.1.1.tar.gz" } ] }