我能夠在我的Django-allauth註冊表單上獲得noRecaptcha表單,並使用使用脆皮形式的模板。 Using this answerDjango Reoder norecaptcha字段使用脆皮形式註冊allauth
這個問題實際上是關於當表單包含在django-allauth中並且沒有指定佈局時(每個作者),在脆性佈局佈局上強制字段順序。因此,當用自己的自定義格式覆蓋註冊表單時,我試圖指定一個佈局,但不知道我是否能夠識別它。
結合其他職位的答案:
from django import forms
from neatf.users.models import User
from nocaptcha_recaptcha.fields import NoReCaptchaField
class AllauthSignupForm(forms.Form):
captcha = NoReCaptchaField()
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2', 'captcha']
field_order = ['username', 'email', 'password1', 'password2',
'captcha']
def signup(self, request, user):
""" Required, or else it throws deprecation warnings """
pass
我敢肯定,我有錯誤的模型中引用,或者它根本不理。 noRecaptcha字段只是坐在窗體的頂部,而不是我想要的底部。
我也試過使用FormHelper - 但必須明確地做錯了。
helper = FormHelper()
helper.form_class = '.form-inline'
helper.field_template = 'bootstrap4/layout/inline_field.html'
helper.layout = Layout(
Fieldset('Contact data', 'username', 'email',),
Fieldset('Password', 'password1', 'password2', 'captcha'))
我寧願不寫模板,並希望有一種方法來覆蓋佈局。
我有django-allauth(0.31.0),並且使用你的代碼,在電子郵件(顯示命令:用戶名,電子郵件,recaptcha,password1,password2)後,我將recaptcha移動到中間位置。一個改進,但不知道如何強制驗證碼到最後。謝謝 – wedward