重写Django表单中的标签

2024-10-04 01:22:09 发布

您现在位置:Python中文网/ 问答频道 /正文

除了“标题”字段上的标签外,我有3个部分具有相同的字段。 对他们来说,我用的是同一种Django形式。在

在我看来:

def get(self):
    context = self.CONTEXT_CLASS(self.MODEL_CLASS)
    context.messages = self.get_messages()
    context.section1 = InvoiceContentForm()
    context.section2 = InvoiceContentForm()
    context.section3 = InvoiceContentForm()
    self.render_jinja('templates/invoice/add_edit.html', context.as_dict)

我的表格:

^{pr2}$

有什么方法可以在分配给context.section1 = InvoiceContentForm()时更改InvoiceContentForm()上的标题标签吗?在


Tags: djangoself标题getmodeldefcontext标签