Я пытаюсь использовать recaptcha https://github.com/praekelt/django-recaptcha в моем django проекте во время разработки. Я добавил «localhost» в свои домены и думаю, что мои настройки верны, но страница просто загружается вечно. Вот мой программный код:
settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth', #Core authentication framework and its default models.
'django.contrib.contenttypes', #Django content type system (allows permissions to be associated with models).
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_cleanup.apps.CleanupConfig',
'tinymce',
'crispy_forms',
'captcha',
'main',
]
RECAPTCHA_PUBLIC_KEY = '...'
RECAPTCHA_PRIVATE_KEY = '...'
RECAPTCHA_DOMAIN = 'www.recaptcha.net'
forms.py
from captcha.fields import ReCaptchaField
class CreateDealerForm(forms.ModelForm):
captcha = ReCaptchaField()
class Meta:
model = Dealer
featured_image = ImageField(widget=PictureWidget)
fields = ('name', 'phone','website', 'address', 'featured_image',)
widgets = {
'name': forms.TextInput(attrs={'class': 'dealer-name-field', 'placeholder': 'Dealer name'}),
'phone': forms.TextInput(attrs={'class': 'dealer-phone-field', 'placeholder': 'Dealer phone'}),
'website': forms.TextInput(attrs={'class': 'dealer-website-field', 'placeholder': 'Dealer website'}),
'address': forms.TextInput(attrs={'class': 'dealer-address-field', 'placeholder': 'Dealer address'}),
}
шаблон
<div class="container">
<div class="card">
<form enctype="multipart/form-data" method="POST">
{% csrf_token %}
{{ form|crispy }}
<img href="{{dealer.featured_image.url}}">
{{ form.errors }}
<br>
<button type="submit" class="btn submit-btn mt-3 mr-2"><i class="fa fa-share"></i> Submit</button>
</form>
</div>
</div>