login with captcha

This commit is contained in:
wcharles 2019-10-09 16:36:18 +08:00
parent 865579f8d2
commit b79aeace36
2 changed files with 4 additions and 2 deletions

View File

@ -4,4 +4,4 @@ from captcha.fields import CaptchaField
class GroupsForm(forms.Form):
username = forms.CharField(label="用户名", max_length=128, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': "Username",'autofocus': ''}))
password = forms.CharField(label="密码", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control','placeholder': "Password"}))
captcha = CaptchaField(label='验证码', error_messages={"invalid":"验证码错误"})
captcha = CaptchaField(label='验证码', error_messages={"invalid":"验证码错误"})

View File

@ -50,8 +50,10 @@
</body>
</html>
<script>
$(function(){
$('#id_captcha_1').addClass('form-control');
})
$('.captcha').click(function () {
$.getJSON("/groups/refresh_captcha/", function (result) {
$('.captcha').attr('src', result['image_url']);
$('#id_captcha_0').val(result['key'])