I recently used similar stuff and IIRC recaptcha2 doesn't use one of those
fields anymore.

pe 20. huhtikuuta 2018 klo 17.40 DougN <[email protected]> kirjoitti:

> I'm new to django and trying to figure out how some of the form processing
> works.
>
> For example, I have this field:
>
> class ReCaptchaField(forms.Field):
>     def __init__(self, *args, **kwargs):
>         super(ReCaptchaField, self).__init__(widget=ReCaptchaWidget)
>
> The widget renders some HTML (reCaptcha2 stuff).
>
> I understand the concept of Field.clean, but the existing code is cleaning
> an array, and I haven't been able to work out where those values come from
> or what they are:
>
> def clean(self, values):
>         super(ReCaptchaField, self).clean(values[1])
>         recaptcha_challenge_value = smart_unicode(values[0])
>         recaptcha_response_value = smart_unicode(values[1])
>         ... code to do stuff with the values
>
> How can I figure out what those incoming values are?   The widget has a
> value_from_datadict, but I can't see where those values get populated
> either.
>
> class ReCaptchaWidget(forms.Widget):
>     def render(self, name, value, attrs=None):
>         return
> mark_safe(force_unicode(captcha.displayhtml(settings.RECAPTCHA_PUB_KEY)))
>
>     def value_from_datadict(self, data, files, name):
>         return data.get('recaptcha_challenge_field', None),
> data.get('recaptcha_response_field', None)
>
> For example, there are variables named recaptcha_challenge_field, but that
> string literal isn't used anywhere else.  Seems like magic going on here...
> ;(
>
> Thanks for any pointers.
>
> Doug
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2630b767-678b-4f29-879a-4c2d01a3e252%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2630b767-678b-4f29-879a-4c2d01a3e252%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofxUbr0k7dzL0C3WoQot13vDzNLcQ6SUpmaxa16opNSBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to