Python 使模型形状酥脆
我试图显示我所有的模型项目,但添加了一些脆元素。但是,它在模型表单字段上方显示我的html和按钮,而不是在html下方和按钮上方 表格Python 使模型形状酥脆,python,django,django-crispy-forms,Python,Django,Django Crispy Forms,我试图显示我所有的模型项目,但添加了一些脆元素。但是,它在模型表单字段上方显示我的html和按钮,而不是在html下方和按钮上方 表格 class BusinessForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(BusinessForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self)
class BusinessForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(BusinessForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.form_class = 'form-horizontal'
self.helper.form_action = 'update'
self.helper.form_method = 'post'
self.helper.layout = Layout(
HTML("<p class='alert-info alert'>Please confirm your business contact information is updated and correct.</p>"),
Div(
FormActions(
Submit('save_changes', 'Save changes', css_class="btn-primary"),
),
css_class='row-fluid'
)
)
# self.helper.add_input(Submit('save_changes', 'Save changes', css_class="btn-primary"))
class Meta:
model = Business
exclude = ('inactive',)
然而,我看到它在表单下方显示了我的模型字段,我甚至尝试了一个add\u input
,它做了同样的事情。如何使我的模型表单字段显示在警报信息
和提交按钮上方
def index(request, token):
try:
business = Business.objects.get(token__token=token)
except Token.DoesNotExist:
business = None
except Business.DoesNotExist:
business = None
return render(request, 'business/index.html', {'form': BusinessForm(instance=business)})