[Fixed]-Django add an attribute class form in __init__.py

1👍

You need to assign the field to form.fields, not just form.

However this is not really the way to do this. Instead, you should make all your forms inherit from a shared parent class, which defines the captcha field.

0👍

Continuing from a comment, have a base class inherit from django.forms.Form, and subclass it for all the forms you want a captcha field on;

from captcha.fields import ReCaptchaField
from django.forms import Form

class CaptchaMixin():
    captcha = ReCaptchaField()

class ActualForm(CaptchaMixin, Form):
    pass
👤Mause

Leave a comment