python - AttributeError 'tuple' object has no attribute 'get' -


i have django application. can't error have been struggling time now.

exception value: 'tuple' object has no attribute 'get'  exception location: /library/python/2.7/site-packages/django/middleware/clickjacking.py in process_response, line 30 

and traceback django provides me.

traceback: file "/library/python/2.7/site-packages/django/core/handlers/base.py" in get_response 201.                 response = middleware_method(request, response) file "/library/python/2.7/site-packages/django/middleware/clickjacking.py" in process_response 30.         if response.get('x-frame-options', none) not none: 

i have hard time figuring out why error occurs. how can find out tuple in code?

the view:

def products(request, category=none, gender=none, retailer_pk=none, brand_pk=none):     # if request doesn't have referer use full path of url instead.     if not request.meta.get("http_referer", none):         referer = request.get_full_path()     else:         referer = request.meta.get("http_referer")      if gender:         products = productslave.objects.filter(q(productmatch__stockitem__stock__gt=0) &                                                q(productmatch__slave_product__master_product__gender=gender)).distinct()     elif brand_pk:         products = productslave.objects.filter(q(master_product__brand__pk=brand_pk))         brand = brand.objects.get(pk=brand_pk)     elif retailer_pk:         retailer = retailer.objects.get(pk=retailer_pk)         products = retailer.productmatch_set.all()     else:         products = productslave.objects.filter(q(productmatch__stockitem__stock__gt=0))      if not retailer_pk:         filt = create_filtering(productslaves=products, request=request)     elif retailer_pk:         filt = create_filtering(productmatches=products, request=request)      sorting_selected = request.get.get("sorter", none)      # q_list used store q's     # reduced. , filtered     if "brand" in request.get:         brand_filtering = request.get.get("brand", none)         if brand_filtering:             brand_filtering = brand_filtering.split("|")         q_list = []         filter in brand_filtering:             if retailer_pk:                 q_list.append(q(slave_product__master_product__brand__slug=filter))             else:                 q_list.append(q(master_product__brand__slug=filter))         reduced_q = reduce(operator.or_, q_list)         products = products.filter(reduced_q)      if "kategori" in request.get:         category_filtering = request.get.get("kategori", none)         if category_filtering:             category_filtering = category_filtering.split("|")         q_list = []         filter in category_filtering:             if retailer_pk:                 q_list.append(q(slave_product__master_product__product_category__slug=filter))             else:                 q_list.append(q(master_product__product_category__slug=filter))         reduced_q = reduce(operator.or_, q_list)         products = products.filter(reduced_q)      if "stoerrelse" in request.get:         size_filtering = request.get.get("stoerrelse", none)         if size_filtering:             size_filtering = size_filtering.split("|")         q_list = []         filter in size_filtering:             if retailer_pk:                 q_list.append(q(slave_product__productmatch__stockitem__size__pk=filter))             else:                 q_list.append(q(productmatch__stockitem__size__pk=filter))         reduced_q = reduce(operator.or_, q_list)         products = products.filter(reduced_q)      if "farve" in request.get:         color_filtering = request.get.get("farve", none)         if color_filtering:             color_filtering = color_filtering.split("|")         q_list = []         filter in color_filtering:             if retailer_pk:                 q_list.append(q(slave_product__sorting_color__slug=filter))             else:                 q_list.append(q(sorting_color__slug=filter))         reduced_q = reduce(operator.or_, q_list)         products = products.filter(reduced_q)      if "pris" in request.get:         price_filtering = request.get.get("pris", none)         if price_filtering:             price_filtering = price_filtering.split("|")         q_list = []         if retailer_pk:             q_list.append(q(price__gte=price_filtering[0]))             q_list.append(q(price__lte=price_filtering[1]))         else:             q_list.append(q(productmatch__price__gte=price_filtering[0]))             q_list.append(q(productmatch__price__lte=price_filtering[1]))         reduced_q = reduce(operator.and_, q_list)         products = products.filter(reduced_q)      if sorting_selected:         if sorting_selected == filt["sorting"][0]["name"]:             filt["sorting"][0]["active"] = true             if retailer_pk:                 products = products.annotate().order_by("-price")             else:                 products = products.annotate().order_by("-productmatch__price")         elif sorting_selected == filt["sorting"][1]["name"]:             if retailer_pk:                 products = products.annotate().order_by("price")             else:                 products = products.annotate().order_by("productmatch__price")             filt["sorting"][1]["active"] = true         elif sorting_selected == filt["sorting"][2]["name"]:             filt["sorting"][2]["active"] = true             if retailer_pk:                 products = products.order_by("pk")             else:                 products = products.order_by("pk")         else:             if retailer_pk:                 products = products.order_by("pk")             else:                 products = products.order_by("pk")     else:         if retailer_pk:             products = products.order_by("pk")         else:             products = products.order_by("pk")      if brand_pk:         return render(request, 'page-brand-single.html', {             'products': products,             "sorting": filt["sorting"],             "filtering": filt["filtering"],             "brand": brand,         })     elif retailer_pk:         return (request, 'page-retailer-single.html', {             "products": products,             "sorting": filt["sorting"],             "filtering": filt["filtering"],             "retailer": retailer,         })     else:         return render(request, 'page-product-list.html', {             'products': products,             "sorting": filt["sorting"],             "filtering": filt["filtering"]         }) 

you returning tuple here:

elif retailer_pk:     return (request, 'page-retailer-single.html', {         "products": products,         "sorting": filt["sorting"],         "filtering": filt["filtering"],         "retailer": retailer,     }) 

did forget add render there perhaps:

elif retailer_pk:     return render(request, 'page-retailer-single.html', {         "products": products,         "sorting": filt["sorting"],         "filtering": filt["filtering"],         "retailer": retailer,     }) 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -