Monday, March 27, 2017

Re: Django Captcha Ajax call not working

Hi,

 

{% if field.name = 'captcha' %}

 

assigns 'captcha' to field.name and returns if that succeeded. So it's always true. You probably mean:

{% if field.name == 'captcha' %}

 

From what you describe, testfield shows up and your template code says it shouldn't show up.

 

However, when debugging a problem, always reduce to the simplest case, so try with this template code:

 

<form id ="captcha_form" class="captcha_form" action="" method="post">{%csrf_token%}

{{ form }}

<input type="submit" id="button" class="button" onclick="captcha()" value="Invio"/>

</form>

 

On Monday 27 March 2017 05:43:53 valerio orfano wrote:

> testfield is where i type my captcha, sorry

>

> On Monday, March 27, 2017 at 2:38:15 PM UTC+2, valerio orfano wrote:

> > Hi Melvyn thanx for ur reply,

> >

> > this is my form.

> >

> > class AjaxForm(forms.ModelForm):

> > captcha = CaptchaField()

> >

> > class Meta:

> > model = ajaxModel

> > exclude = []

> >

> > class ajaxModel(models.Model):

> > testfield = models.TextField(null=True, blank=True)

> >

> > If i don't use a ajaxmodel a get an error, so testfield is just a

> > dummy field, just to avoid error.

> >

> > valerio

> >

> > On Monday, March 27, 2017 at 2:22:44 PM UTC+2, Melvyn Sopacua wrote:

> >> On Monday 27 March 2017 04:46:06 valerio orfano wrote:

> >> > {% if field.name = 'captcha' %}

> >>

> >> It may not make a difference if you only have one visible field,

> >> but this is not a comparison.

> >>

> >>

> >> Melvyn Sopacua

 

--

Melvyn Sopacua

No comments:

Post a Comment