Hi Alexander,
Although I no longer use captcha on the form in question anymore, I recall
that I did eventually get it working by adding something like the following
in my html to generate the captcha component:
<label for="{{ signup_form.captcha.auto_id }}">{{ signup_form.captcha.label
}}</label>
{{ signup_form.captcha }}<span class="error">{{
signup_form.captcha.errors }}</span>
thanks,
Mark
On Tuesday, March 5, 2013 1:10:42 PM UTC+11, mmuk2 wrote:
>
> Hi,
>
> I'm currently trying to implement django simple captcha on my form. It's
> quite straight forward to set up with the "out of the box" django form
> functionality - just add a captcha field to the form in forms.py, and in
> the template, use the built in django form template like this:
>
> {% form.as_ul %}
>
> And this dynamically generates the HTML for all my form fields including
> the captcha field:
>
> <label for="id_captcha_1">Captcha:</label>
> <img class="captcha" alt="captcha"
> src="/captcha/image/7114a37ed0f72ec3105510e0f5c73128a2f95649/">
> <input id="id_captcha_0" type="hidden"
> value="7114a37ed0f72ec3105510e0f5c73128a2f95649" name="captcha_0">
> <input id="id_captcha_1" type="text" name="captcha_1">
>
> My issue is that I can't use {% form.as_ul %} to display my form, because
> each field requires customised css styling.
>
> So I'll need to replace the {% form.as_ul %} with the actual HTML code in
> my template.
>
> This works fine, however, the captcha field value needs to be re-generated
> each time, so I need to generate the captcha field value dynamically each
> time the form is loaded.
>
> What is the best way to do this? I guess I'm looking for something similar
> to the way the csrf token works, ie. the {% csrf_token %} tag, which
> dynamically generates the csrf token. Is there an equivalient for simple
> captcha, like {% captcha_value %} or something?
>
> thanks in advance,
> Mark
>
--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/cc653d53-e48f-4e2c-be4a-1706e242906d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.