How to get value from form field in django framework?

前端 未结 5 1887
一生所求
一生所求 2020-11-28 05:08

How do I get values from form fields in the django framework? I want to do this in views, not in templates...

5条回答
  •  自闭症患者
    2020-11-28 05:51

    You can do this after you validate your data.

    if myform.is_valid():
      data = myform.cleaned_data
      field = data['field']
    

    Also, read the django docs. They are perfect.

提交回复
热议问题