Display some free text in between Django Form fields

前端 未结 8 637
无人及你
无人及你 2021-02-04 09:00

I have a form like the following:

class MyForm(Form):

  #personal data
  firstname = CharField()
  lastname = CharField()

  #education data
  university = Char         


        
8条回答
  •  不思量自难忘°
    2021-02-04 09:33

    Remember also that a Django Form object is just a collection of fields; there is no need for a 1:1 correspondence between HTML form tags and Django Form objects. If the various sections of the form are actually logically separate, you could consider splitting it up into three Forms, which you could then render in your template with any HTML you want between them (but still within a single HTML form tag).

    Whether this is a sensible solution depends quite a bit on the design of your app and the view, of course.

提交回复
热议问题