當我嘗試運行編輯部件時,出現以下錯誤。在網頁中顯示數據庫中的項目並編輯
在網頁上顯示數據庫的內容工作正常。我已經爲編輯部分提供了代碼。/
類型錯誤在/編輯
__init__()
恰恰1參數(2給出)
views.py
class userUpdate(UpdateView):
model = user
fields = ['name','phone','dob','gender']
template_name_suffix = '_update_form'
urls.py
from django.conf.urls import include, url
from newapp import views
urlpatterns = [url(r'^edit/',views.userUpdate, name = 'user_update_form'),]
user_update_form。 html
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Update" />
</form>
獲得通過Mymodel.objects.all所有對象(),並通過上下文的視圖模板發送。 – Sagar
我刪除了大部分無法解決問題的代碼。 (見[MCVE])。你應該顯示完整的錯誤,幷包括你自己迄今爲止所做的。 – Sayse