Generic detail view DetailView must be called with either an object pk or a slug.

来源:互联网 发布:陈都灵演技知乎 编辑:程序博客网 时间:2024/05/16 13:05

解决办法

 url(r'^(?P<poll_id>\d+)/$',-$                                                url(r'^(?P<poll_id>\d+)/results/$',-$                                       

This is the correct core:

 url(r'^(?P<pk>\d+)/$',-$                                                url(r'^(?P<pk>\d+)/results/$',-$                                       

把URL捕获的组名称改为pk

参照:

http://stackoverflow.com/questions/12304050/django-tutorial-generic-views-attribute-error

0 0