Posts

Showing posts with the label django-recaptcha

Overriding Templates widget templates: django.template.exceptions.TemplateDoesNotExist

Image
 Zie jobsites > jobfor > widgets.py ( CustomReCaptchaV3) For others who stumble on this and are unable to set the FORM_RENDERER, I did the following which ended up working for me: Subclass the  ReCaptchaV3  and override the  render method() : # myproject/widgets.py from captcha.widgets import ReCaptchaV3 from django.template import loader from django.utils.safestring import mark_safe class CustomReCaptchaV3(ReCaptchaV3): template_name = "recaptcha/widget_v3.html" def render(self, name, value, attrs=None, renderer=None): context = self.get_context(name, value, attrs) template = loader.get_template(self.template_name) ⬅️⬅️⬅️⬅️⬅️ **Used template loader ** return mark_safe(template.render(context)) Then use Subclass the  ReCaptchaField  and override the  widget  and  default_error_messages : # myproject/fields.py from django import forms from django.utils.translation import gettext_lazy as _ from captcha....