Skip to main content

Django / Rest Framework Captcha

Project description

Redj Captcha

Django / Rest Framework captcha Safe, flexible and easy to use

Getting Started

in setting.py:

INSTALLED_APPS = [
    ...
    'redjcaptcha',
]

in terminal python manage.py migrate

in urls.py :

from django.urls import path, include

urlpatterns = [
    ...
    path('', include('redjcaptcha.urls')),
]

and check check http://localhost:8000/captcha

check Captcha (django):

from redjcaptcha.setup import checkCaptcha

check = checkCaptcha(captcha_key, captcha_value)
if check==False:
    return 'inValid'

or use fullCheckCaptcha for check ip and User-agent

from redjcaptcha.setup import fullCheckCaptcha

check = fullCheckCaptcha(request)
if check==False:
    return 'inValid'

check Captcha (rest_framework):

from rest_framework import serializers
from redjcaptcha.setup import checkCaptcha

class CaptchaSerializer(serializers.Serializer):
    captcha_key = serializers.CharField()
    captcha_value = serializers.CharField()

    def validate(self, data):
        check = checkCaptcha(data['captcha_key'], data['captcha_value'])
        if check==False:
            print('\n=====> Captcha faild')
            raise Exception()

        print('\n=====> Captcha success')
        return check

if use Redj Log pakeg:

from redjcaptcha import redjlog

redjlog.fullCheckCaptcha(request)

change default setting:

from redjcaptcha.setup import init

init(
    size=6, => count of word
    debug=True, => disable captcha
    font_size=50, => font size
    timeout=6000, => expire captcha after 6000s
    type="str-int", => type of captcha : int | str | str-int
    image_height=70, => image height
    image_weight=180, => image weight
    text_color="random", => text color (defualt random)
    pre_request_inVmin= 10, => max request in 5 minits
    background_color="#fff" => background image or #00000040
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Redj Captcha-1.1.8.tar.gz (42.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Redj_Captcha-1.1.8-py3-none-any.whl (44.3 kB view details)

Uploaded Python 3

File details

Details for the file Redj Captcha-1.1.8.tar.gz.

File metadata

  • Download URL: Redj Captcha-1.1.8.tar.gz
  • Upload date:
  • Size: 42.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for Redj Captcha-1.1.8.tar.gz
Algorithm Hash digest
SHA256 7b8cee8441061efd8a51a95bba743765d4e1ed43825a600609106a68666c4a62
MD5 3d87ef049065c1fe5a1da00d402eb6d4
BLAKE2b-256 f135d940853947c19f611a516a2bf6e8fb84a92b26201b364cb597c3b1d9d0cd

See more details on using hashes here.

File details

Details for the file Redj_Captcha-1.1.8-py3-none-any.whl.

File metadata

  • Download URL: Redj_Captcha-1.1.8-py3-none-any.whl
  • Upload date:
  • Size: 44.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for Redj_Captcha-1.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 450d4aa0099315ac6b971ac5b90e89fc6286643a11e72b4571b266e2771bd6c2
MD5 5654af64cc805b25d4c9aea0774d515d
BLAKE2b-256 84d905ffa0709e8f3c8af9a4e07ff86fc655373e14746c9e479c12aed0a39031

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page