10

I've run into this error:

'function' object has no attribute 'get'

Which looks like it is occurring with clickjacking

Here is the full traceback

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})

2 Answers 2

33

as_view() method returns view function which you need to call with request argument:

return ListView.as_view(.....)(request)
Sign up to request clarification or add additional context in comments.

Comments

1

It is Probably the view you are forwarding to doesn't handle GET requests.. Tweak your View to little like:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.