Simple captha for django-rest-framework
Project description
# Django rest capthca
This is lightweight version of django-simple-captcha for work with
django-rest-framework.
## Features
- speed: use cache insted database
- safety: union methods for generate key and image. (You can't generate many images for one key)
- easy: only one rest api (for generate, refresh image).
## Install
```
> pip install django-rest-captcha
```
## Add to project
Add to installed apps
```
INSTALLED_APPS = (
...
'rest_framework',
)
```
Set rest_captcha serrings (if you want):
```
REST_CAPTCHA = {
'CAPTCHA_CACHE': 'default',
'CAPTCHA_TIMEOUT': 300, # 5 minuts
'CAPTCHA_LENGTH': 4,
'CAPTCHA_FONT_SIZE': 22,
'CAPTCHA_IMAGE_SIZE': (90, 40),
'CAPTCHA_LETTER_ROTATION': (-35, 35),
'CAPTCHA_FOREGROUND_COLOR': '#001100',
'CAPTCHA_BACKGROUND_COLOR': '#ffffff',
'CAPTCHA_FONT_PATH': FONT_PATH,
'CAPTCHA_CACHE_KEY': 'rest_captcha_{key}.{version}',
'FILTER_FUNCTION': 'rest_captcha.captcha.filter_default',
'NOISE_FUNCTION': 'rest_captcha.captcha.noise_default'
}
```
We recommendete use radis or lacal memory as cache with set parameter, with bigger value of MAX_ENTRIES:
```
CACHES={
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'rest-captcha',
'MAX_ENTRIES': 10000,
}
}
```
This is lightweight version of django-simple-captcha for work with
django-rest-framework.
## Features
- speed: use cache insted database
- safety: union methods for generate key and image. (You can't generate many images for one key)
- easy: only one rest api (for generate, refresh image).
## Install
```
> pip install django-rest-captcha
```
## Add to project
Add to installed apps
```
INSTALLED_APPS = (
...
'rest_framework',
)
```
Set rest_captcha serrings (if you want):
```
REST_CAPTCHA = {
'CAPTCHA_CACHE': 'default',
'CAPTCHA_TIMEOUT': 300, # 5 minuts
'CAPTCHA_LENGTH': 4,
'CAPTCHA_FONT_SIZE': 22,
'CAPTCHA_IMAGE_SIZE': (90, 40),
'CAPTCHA_LETTER_ROTATION': (-35, 35),
'CAPTCHA_FOREGROUND_COLOR': '#001100',
'CAPTCHA_BACKGROUND_COLOR': '#ffffff',
'CAPTCHA_FONT_PATH': FONT_PATH,
'CAPTCHA_CACHE_KEY': 'rest_captcha_{key}.{version}',
'FILTER_FUNCTION': 'rest_captcha.captcha.filter_default',
'NOISE_FUNCTION': 'rest_captcha.captcha.noise_default'
}
```
We recommendete use radis or lacal memory as cache with set parameter, with bigger value of MAX_ENTRIES:
```
CACHES={
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'rest-captcha',
'MAX_ENTRIES': 10000,
}
}
```
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
django-rest-captcha-0.0.3.tar.gz
(52.4 kB
view hashes)
Close
Hashes for django-rest-captcha-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18f5d599a03426170efc76884eaff8000e6282d734f634451712a12c2d8a227f |
|
MD5 | 1e280a25cfcece32bcb546543d086f84 |
|
BLAKE2b-256 | ae515b259d27b96ee8c23d6fc57a5dd0b22540b99adb97bb74623f4325a872e8 |