Django


1687 浏览 6 years, 1 month

5 视图 URL & View

版权声明: 转载请注明出处 http://www.codingsoho.com/

Redirection

自动跳转

return HttpResponseRedirect('/register/success')

direct_to_template() 在 django 取消了。

可以这么写

from django.conf.urls import patterns
from django.views.generic import TemplateView
urlpatterns = patterns('',
     (r'^register/success/$', TemplateView.as_view(template_name = 'registration/register_success.html' )),
)    

reverse

Issue

'url' requires a non-empty first argument. . The syntax changed in Django 1.5, see the docs.

从django1.5 开始

{% url blocontent blog_id=id %}"

需要修改为:

{% url ‘blog_content’ blog_id=id %}"

Django updateview 里如何显示User