Django function object does not have 'get' attribute

I ran into this error:

'function' object has no attribute 'get'

It looks like this is happening with clickjacking

Here is the full trace

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'

My view and URL:

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})
+4
source share
2 answers

as_view()The method returns a view function that you must call with an argument request:

return ListView.as_view(.....)(request)
+15
source

It is likely that the view you are sending does not handle GET requests. Adjust your look as if:

class logout_view(View):
def get(self,request):
    logout(request)
    return redirect('appname:view')
+1
source

All Articles