I've gone through some solutions for a similar problem but none of these worked:
'WSGIRequest' object has no attribute 'session'
'WSGIRequest' object has no attribute 'facebook'
I'm building a search page which is as follows:
views.py
def search(request):
if 'query' in request.GET and request.GET['query']:
q = request.GET['query']
ct = Product.objects.filter(Q(name__icontains=q) | Q(desc__icontains=q) | Q(category__icontains=q))
count = ct
paginate = Paginator(ct, 10)
page = request.GET.get('page')
try:
ct = paginate.page(page)
except PageNotAnInteger:
ct = paginate.page(1)
except EmptyPage:
ct = paginate.page(paginate.num_pages)
dictionary = {'results': ct, 'count': count, 'query': q, }
return render_to_response('search.html', dictionary, request)
else:
content = {'contentnotfound': 'Hi, you did not search for anything. Please go back or use the search box above.'}
return render(request, 'search.html', content)
The complete traceback for this is:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/search?query=abc&submit=Submit
Django Version: 1.6.4
Python Version: 2.7.3
Installed Applications:
('django_admin_bootstrapped.bootstrap3',
'django_admin_bootstrapped',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Abstract',
'south',
'djrill',
'storages',
's3direct')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/home/siddharth/AbstractIndia/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/siddharth/AbstractIndia/Abstract/views.py" in search
39. return render_to_response('search.html', dictionary, request)
File "/home/siddharth/AbstractIndia/venv/local/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
29. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/home/siddharth/AbstractIndia/venv/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
167. context_instance.update(dictionary)
Exception Type: AttributeError at /search
Exception Value: 'WSGIRequest' object has no attribute 'update'
urls.py is as follows:
url(r'^search$', views.search, name='search'),
I've done the same thing before with another project and it worked perfectly.