Using Django Forms to display and edit?

前端 未结 4 500
天命终不由人
天命终不由人 2021-02-09 01:36

I\'m wrestling with how to best create HTML pages in Django that can either be used for displaying or editing data. That is, I\'d like the field\'s values to appear as text in d

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-09 02:21

    Since you are saving the data, you must have a model attached to the form somehow, a modelform or not. So you can just use that model directly to get the values and render it in a template like you want.

    The above suggestion would be possible, but since forms can be rather complex, it's probably not an easy task or worth the bother. Depends on how often you want to do this. But then it would probably be easier to create a filter for the model instead of the form.

提交回复
热议问题