gpt4 book ai didi

Django 'function'对象没有属性 'get'

转载 作者:行者123 更新时间:2023-12-04 05:38:24 26 4
gpt4 key购买 nike

我遇到了这个错误:

'function' object has no attribute 'get'

看起来像是发生在点击劫持中

这是完整的追溯
Request Method: GET
Request URL: http://localhost:8000/weblog/categories/weekly/

Django Version: 1.7
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'search',
'coltrane',
'tagging',
'markdown')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
204. response = middleware_method(request, response)
File "/Library/Python/2.7/site-packages/django/middleware/clickjacking.py" in process_response
31. if response.get('X-Frame-Options', None) is not None:

Exception Type: AttributeError at /weblog/categories/weekly/
Exception Value: 'function' object has no attribute 'get'

我的 View 和网址:
url(r'^(?P<slug>[-\w]+)/$', 'coltrane.views.category_detail', {},
name='coltrane_category_detail'),

def category_detail(request, slug):
category = get_object_or_404(Category, slug=slug)
return ListView.as_view(queryset=category.live_entry_set(),
context_object_name={'category': category})

最佳答案

as_view()方法返回需要使用request参数调用的 View 函数:

return ListView.as_view(.....)(request)

关于Django 'function'对象没有属性 'get',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27436950/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com