app-engine-patch 和“object_detail”视图不起作用

发布于 2024-08-30 07:29:43 字数 2839 浏览 2 评论 0原文

嗨(抱歉我的英语不好) 我想使用app-engine-patch和google app引擎创建一个简单的博客,并使用django通用视图处理博客入口页面。 但是当我使用 Django 的通用视图“django.views.generic.list_detail.object_detail”时,我遇到了以下错误:

GenericViewError at /blog/entry/

Generic view must be called with either an object_id or a slug/slug_field.

Request Method:     GET
Request URL:    http://192.168.62.90:8000/blog/entry/
Exception Type:     GenericViewError
Exception Value:    

Generic view must be called with either an object_id or a slug/slug_field.

Exception Location:     <unknown> in ?, line ?
Python Executable:  /usr/bin/python
Python Version:     2.5.2
Python Path:    ['/home/hugh/Desktop/app-engine-patch-sample', '/home/hugh/Desktop/app-engine-patch-sample/common', '/home/hugh/Desktop/app-engine-patch-sample/common/appenginepatch/appenginepatcher/lib', '/home/hugh/Desktop/app-engine-patch-sample/common/zip-packages/django-1.0.2.zip', '/home/hugh/Desktop/app-engine-patch-sample/common/appenginepatch', '/home/hugh/Desktop/google_appengine', '/home/hugh/Desktop/google_appengine/lib/django', '/home/hugh/Desktop/google_appengine/lib/antlr3', '/home/hugh/Desktop/google_appengine/lib/webob', '/home/hugh/Desktop/google_appengine/lib/ipaddr', '/home/hugh/Desktop/google_appengine/lib/yaml/lib', '/home/hugh/Desktop/app-engine-patch-sample', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/gst-0.10', '/var/lib/python-support/python2.5', '/usr/lib/python2.5/site-packages/gtk-2.0', '/var/lib/python-support/python2.5/gtk-2.0']
Server time:    Thu, 29 Apr 2010 01:54:57 +0000

此链接导致了上述问题: http://192.168.62.90:8000/blog/entry/?agphdXR1bW4xOTEychALEgpibG9n X2VudHJ5GCYM

我的urls.py:

from django.conf import settings
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

from django.views.generic import list_detail
from blog.models import Author, Entry

entry_info = {
    'queryset': Entry.all().order('-pub_date'),
    'template_name': 'index.html',
    'template_object_name': 'entry',
}

urlpatterns = patterns('',
    (r'^media/(?P<path>.*)$', 'django.views.static.serve',
    {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
    (r'^$', list_detail.object_list, entry_info),
    (r'^entry/(?P<object_id>.*)$', 
        list_detail.object_detail, 
        {'queryset': Entry.all(), 'template_name': 'sample_test_page.html'}),

)

我不知道这个错误的原因。

Hi(Sorry for my ugly english)
I want to use the app-engine-patch and google app engine to create a simple blog, and use the django generic views handle the blog entry page.
But when I use Django's generic views "django.views.generic.list_detail.object_detail", I encountered an error in the following:

GenericViewError at /blog/entry/

Generic view must be called with either an object_id or a slug/slug_field.

Request Method:     GET
Request URL:    http://192.168.62.90:8000/blog/entry/
Exception Type:     GenericViewError
Exception Value:    

Generic view must be called with either an object_id or a slug/slug_field.

Exception Location:     <unknown> in ?, line ?
Python Executable:  /usr/bin/python
Python Version:     2.5.2
Python Path:    ['/home/hugh/Desktop/app-engine-patch-sample', '/home/hugh/Desktop/app-engine-patch-sample/common', '/home/hugh/Desktop/app-engine-patch-sample/common/appenginepatch/appenginepatcher/lib', '/home/hugh/Desktop/app-engine-patch-sample/common/zip-packages/django-1.0.2.zip', '/home/hugh/Desktop/app-engine-patch-sample/common/appenginepatch', '/home/hugh/Desktop/google_appengine', '/home/hugh/Desktop/google_appengine/lib/django', '/home/hugh/Desktop/google_appengine/lib/antlr3', '/home/hugh/Desktop/google_appengine/lib/webob', '/home/hugh/Desktop/google_appengine/lib/ipaddr', '/home/hugh/Desktop/google_appengine/lib/yaml/lib', '/home/hugh/Desktop/app-engine-patch-sample', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/gst-0.10', '/var/lib/python-support/python2.5', '/usr/lib/python2.5/site-packages/gtk-2.0', '/var/lib/python-support/python2.5/gtk-2.0']
Server time:    Thu, 29 Apr 2010 01:54:57 +0000

This link causing the problem above:
http://192.168.62.90:8000/blog/entry/?agphdXR1bW4xOTEychALEgpibG9nX2VudHJ5GCYM

My urls.py:

from django.conf import settings
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

from django.views.generic import list_detail
from blog.models import Author, Entry

entry_info = {
    'queryset': Entry.all().order('-pub_date'),
    'template_name': 'index.html',
    'template_object_name': 'entry',
}

urlpatterns = patterns('',
    (r'^media/(?P<path>.*)

I do not know the reason of this error.

, 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), (r'^

I do not know the reason of this error.

, list_detail.object_list, entry_info), (r'^entry/(?P<object_id>.*)

I do not know the reason of this error.

, list_detail.object_detail, {'queryset': Entry.all(), 'template_name': 'sample_test_page.html'}), )

I do not know the reason of this error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨后彩虹 2024-09-06 07:29:43

我相信您的网址在“?”后缺少“object_id=”。

I believe your URL is missing 'object_id=' after the '?'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文