Answer the question
In order to leave comments, you need to log in
How to fix request.META.HTTP_REFERER reading error?
Hello, I want to change the variable in views by the presence of a specific referrer with the following code:
def startpage(request):
success = False
if request.META.HTTP_REFERER == 'http://127.0.0.1:8000/success':
success = True
return render(request, './index.html', {'success': success})
http://127.0.0.1:8000/success
that redirects to http://127.0.0.1:8000
, i.e. to the start page displayed by startpage()
By clicking on the button, an error page is displayed with the following content:<a href="./">To start page</a>
AttributeError at /
'dict' object has no attribute 'HTTP_REFERER'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question