Display some free text in between Django Form fields

前端 未结 8 640
无人及你
无人及你 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:32

    If you want to customize the form, you don't have to render it form.as_ul. Django knows how to render foobar if you have set up the forms model properly...try it...no worries.

    Look at what python on the server sent your page. For example if it sent a django form like this:

    return respond(request, user, 'templateName', { 'myform':myform })

    then templateName.html will have:

    Here you enter your personal data...

    {{myform.firstname }}

    Here you enter your education data...

    {{myform.university }}

    a choice field

    {{myform.foobar}}

提交回复
热议问题