Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'dict' object has no attribute 'HTTP_REFERER'

I've been trying to find the previous url following this answer:

Django request to find previous referrer

So, in my .py I did:

print request.META
print request.META.HTTP_REFERER
print request.META['HTTP_REFERER']

request.META returns:

{'RUN_MAIN': 'true', 'HTTP_REFERER': 'http://127.0.0.1:8000/info/contact/', 'XDG_GREETER_DATA_DIR': '/var/lib/lightdm-data/user', 'QT4_IM_MODULE': 'xim',....

So, I can see HTTP_REFERER is there, but when trying to access it either way I get the error:

<type 'exceptions.AttributeError'>
'dict' object has no attribute 'HTTP_REFERER'

How can I access it?

like image 978
Didina Deen Avatar asked Dec 15 '22 02:12

Didina Deen


1 Answers

I would suggest:

request.META.get('HTTP_REFERER')
like image 71
sheilapbi Avatar answered Jan 01 '23 02:01

sheilapbi