ドキュメントを読んで、クリスピーフォームに関するチュートリアルを読みました。https://django-crispy-forms.readthedocs.org/en/d-0/dynamic_layouts.htmlのレイアウトの操作で、非常に役立つことがわかりました。
layout.append(HTML("<p>whatever</p>"))
layout.insert(1, HTML("<p>whatever</p>"))
だから私は試しました:
class PostJobForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout.insert(1, HTML("<p>Drag and drop photos and video here</p><p class='big'>+</p><p>Or click to add using the file browser</p>"),)
super(PostJobForm, self).__init__(*args, **kwargs)
class Meta:
model=Job
exclude=['employer','hitcount','location']
エラーが発生しました
'NoneType' object has no attribute 'insert'
このレイアウトオブジェクトはどこにありますか? チュートリアルでは言及されていません。
どうすれば使えますかlayout.insert(1, HTML("<p>whatever</p>"))