capth 图形验证码

1.views.py

# 获取uuid
uuid = request.GET.get('uuid')

# text 存放图片中的文字     image 存放图片
text,image = captcha.generate_captcha()

# 链接redis
redis_cli = get_redis_connection('img_code')

# 给uuid和文字设置时间
redis_cli.setex(uuid,60*60,text)

# content_type='' 指定类型
return HttpResponse(image,content_type='image/jpg')
原文地址:https://www.cnblogs.com/yimeng123/p/14374381.html