答案 0 :(得分:2)
你可以向下滚动你所指的博客......他们已经详细解释了编辑表格link
简而言之:您必须添加一个新网址来编辑您的用户,如:
url(r'^user/(?P<pk>[0-9]+)$', views.UserEdit),
和观点:
def UserEdit(request, pk):
user = get_object_or_404(User, pk=pk)
if request.method == "POST":
form = UserForm(request.POST, instance=user)
if form.is_valid():
...
return redirect('detail_user', pk=user.pk)
else:
form = UserForm(instance=user)
return render(request, 'user_detail.html', {'form': form})