Django Updateview can';t保存数据并重定向

Django Updateview can';t保存数据并重定向,django,django-views,Django,Django Views,模板 <form action="" method="post">{% csrf_token %} {{ form.as_p }} <input type="submit" value="Update" name="_save" /> </form> 查看 class LabelUpdateView(UpdateView): model = models.SlPannelli exclude=() fields = '

模板

<form action="" method="post">{% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Update" name="_save" />
</form>
查看

class LabelUpdateView(UpdateView):
    model = models.SlPannelli
    exclude=()
    fields = '__all__'
#    form_class = LabelUpdateForm  

    def form_valid(self, form):
        return super(LabelUpdateView, self).form_valid(form)
        return TemplateResponse(self.request, self.template_name, locals())
URL

url(r'^labelch/(?P<pk>\d+)$', views.LabelUpdateView.as_view(), name='label_update'),
url(r'^labelch/(?P\d+)$,views.LabelUpdateView.as_view(),name='label_update'),
我可以看到加载的数据进行更新,但当点击更新按钮时,会继续重定向到“labelch/”页面,无法保存更新的数据

Vedi Informazioni
Funzione View   Argomenti   Parole chiave   Nome URL
<nessuna view>
u'None'
u'None'
None
Cookies
Variabile   Valore
'cookieconsent_dismissed'
'yes'
'csrftoken'
'vUdhIR42Z4c3aCgbeVugQidDHoa8gFby'
'djdt'
'hide'
'sessionid'
'f9957eaw537wg6v8xi069dqq5cqyrvxd'
Dati di sessione
Variabile   Valore
u'_auth_user_backend'
u'django.contrib.auth.backends.ModelBackend'
u'_auth_user_hash'
u'55822a00e348b79b5cd03be74b185995766915a7'
u'_auth_user_id'
u'1'
Nessun dato in GET
Dati POST
Variabile   Valore
u'_save'
[u'Update']
u'csrfmiddlewaretoken'
[u'vUdhIR42Z4c3aCgbeVugQidDHoa8gFby', u'vUdhIR42Z4c3aCgbeVugQidDHoa8gFby']
u'note'
[u'']
u'tipo'
[u'S2']
视频信息 Funzione View Argomenti Parole交叉命名URL 你没有 你没有 没有一个 曲奇饼 可变谷 “cookieconsent_解散” “是的” “csrftoken” “vUdhIR42Z4c3aCgbeVugQidDHoa8gFby” “djdt” “隐藏” “sessionid” 'F9957EAW537WG6V8XI069DQ5CQYRVXD' 达蒂迪塞西翁酒店 可变谷 “授权用户后端” u'django.contrib.auth.backends.ModelBackend' “身份验证用户哈希” u'55822A000E348B79B5CD03BE74B185995766915A7' “身份验证用户id” u'1' 内森达托酒店 达蒂邮政 可变谷 你救了我 [u'更新'] u'csrfmiddlewaretoken' [u'Vudhir42Z4C3ACGBeVugQidHoa8GFBY',u'Vudhir42Z4C3ACGBeVugQidHoa8GFBY'] 注意 [u'] u'tipo' [u'S2'] 这是请求的输出django调试tolbar

[已解决]

url(r'^(?P<pk>\d+)/labelch$', views.LabelUpdateView.as_view(), name='label_update'),
url(r'^(?P\d+)/labelch$,views.LabelUpdateView.as_view(),name='label_update'),
不明白为什么,但是改变URL中pk的顺序解决了所有问题


@西蒙妮:谢谢你的建议,以后一定要记住

-为什么第二次申报表是有效的(自我,表格)?(顺便说一句,永远不要使用locals()技巧,相信我,总有一天你会调试几个小时无法解释的东西)-你确定数据有效吗?尝试覆盖表单并打印错误,可能存在一些错误,而您的模板没有显示这些错误。
url(r'^(?P<pk>\d+)/labelch$', views.LabelUpdateView.as_view(), name='label_update'),