Accessing form fields as properties in a django view

后端 未结 4 622
时光说笑
时光说笑 2020-12-29 09:01

According to the Django tutorial, you should access form fields using cleaned_data dictionary. I\'m wondering why I can\'t access the properties of the form directly? My for

4条回答
  •  借酒劲吻你
    2020-12-29 09:43

    You can access the fields of a Form instance from its fields attribute.

    myForm.fields['description']
    

    And some property like label can be accessed like this:

    myForm.fields['description'].label
    

    Not sure how to display the value corresponding. Anybody having idea?

    here is my reference

    https://docs.djangoproject.com/en/dev/ref/forms/api/#accessing-the-fields-from-the-form

提交回复
热议问题