python - Django 1.6: 'instancemethod' object has no attribute '__getitem__' -



python - Django 1.6: 'instancemethod' object has no attribute '__getitem__' -

i've dropdown menu in template , i'm trying store selection made user filter doc objects. maintain getting error:

traceback: file "/library/python/2.7/site-packages/django/core/handlers/base.py" in get_response 114. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/library/python/2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view 57. homecoming view_func(*args, **kwargs) file "views.py" in doclistings 91. if request.session.get["selection"] == "dentist": exception type: typeerror @ /doclistings/ exception value: 'instancemethod' object has no attribute '__getitem__'

here index template

<div class="signup"> <div class="form-group"> <form action="/doclistings/" method="get" > <select class="form-control" id="selection" name="selection"> <option><b>find doctor...</b></option> {% value, text in form.selection.field.choices %} <option value="{{ value }}">{{ text }}</option> {% endfor %} {% csrf_token %} </select>

here doclisting views i'm trying filter based on selection

def doclistings(request): d = getvariables(request) doctors = doctor.objects.all().order_by('-likes') paginator = paginator(doctors, 20) #show 20 doctors per page page = page = request.get.get('page') # print request.session["selection"] # print request.session.get("selection", none) if request.session.get["selection"] == "dentist": doctors = doctor.objects.filter(specialization = "dentist").order_by('-likes') try: doctors = paginator.page(page) except pagenotaninteger: doctors = paginator.page(1) except emptypage: doctors = paginator.page(paginator.num_pages) d['doctors'] = doctors d['paginator'] = paginator homecoming render_to_response('meddy1/doclistings.html',d)

the doc model has specialisation attribute , i'm trying filter doctors based on user selection.

get method

request.session.get('selection')

python django templates session

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -