I have a Django application. But i can\'t an error that i have been struggling with for some time now.
Exception Value: \'tuple\' object has no attribute \'g
You are returning a tuple here:
elif retailer_pk:
return (request, 'page-retailer-single.html', {
"products": products,
"sorting": filt["sorting"],
"filtering": filt["filtering"],
"retailer": retailer,
})
Did you forget to add render
there perhaps:
elif retailer_pk:
return render(request, 'page-retailer-single.html', {
"products": products,
"sorting": filt["sorting"],
"filtering": filt["filtering"],
"retailer": retailer,
})
Even taking the commas of the views is as simple of a solution
as-in this
def home(request):
return render(request, 'index.html')
def hire(request):
return render(request, 'hire.html')
def handler400(request, exception):
return render(request, '400.html', locals())
def handler403(request, exception):
return render(request, '403.html', locals())
def handler404(request, exception):
return render(request, '404.html', locals())
def handler500(request, exception):
return render(request, '500.html', locals())
Rather than this
def home(request):
return render(request, 'index.html'),
def hire(request):
return render(request, 'hire.html'),
def handler400(request, exception):
return render(request, '400.html', locals()),
def handler403(request, exception):
return render(request, '403.html', locals()),
def handler404(request, exception):
return render(request, '404.html', locals()),
def handler500(request, exception):
return render(request, '500.html', locals())
There is an extra comma "," at the end of return
function in views.py
return render(request, 'index.html',{}), #incorrect
return render(request, 'index.html',{}) #correct