使用django中基于类的视图从数据库中检索url中特定id的值

时间:2022-03-30 19:20:03

I need to display value into textbox fields in template page which is get from the database for the particular id. After that i need to edit those details which is needed and to update those values into database.These things are done by function based views easily. But now i want to do that it in class based views.Which view is used to do that. Can anyone help me to do that.

我需要在模板页面的文本框字段中显示值,该模板页面是从特定id的数据库中获取的。之后我需要编辑所需的细节并将这些值更新到数据库中。这些事情很容易通过基于功能的视图完成。但现在我想在基于类的视图中做到这一点。用哪种视图来做到这一点。任何人都可以帮助我做到这一点。

1 个解决方案

#1


1  

You should use the UpdateView for this task.

您应该使用UpdateView执行此任务。

UPDATE: If you want to display instance details on one page and the edit form on another then use the DetailView for the first step.

更新:如果要在一个页面上显示实例详细信息而在另一个页面上显示编辑表单,请在第一步中使用DetailView。

#1


1  

You should use the UpdateView for this task.

您应该使用UpdateView执行此任务。

UPDATE: If you want to display instance details on one page and the edit form on another then use the DetailView for the first step.

更新:如果要在一个页面上显示实例详细信息而在另一个页面上显示编辑表单,请在第一步中使用DetailView。