WebFaction
Community site: login faq

Hello World!

Can someone point me in the right direction to find out how to dissect HTTP_REFERER? Like, I want to find out what is inside it.

asked 05 Nov '10, 17:43

Sean Lambert
261716
accept rate: 25%


Based on your prior questions, I'm assuming you're working with Django. If that's correct, then you can get the referer header from request.META['HTTP_REFERER'].

There's not much there to dissect - if it's populated at all, it will be the URL of the page that the request came from.

permanent link

answered 05 Nov '10, 18:19

seanf
12.2k42136
accept rate: 37%

Yeah, i'm using django. Is there a way to parse it to a string to actually see the url?

(05 Nov '10, 23:04) Sean Lambert

request.META['HTTP_REFERER'] is already a string. You can see this by passing it to your template directly in the context and printing the value.

If you need to make the 'request' object available to every template, this can be done with the django.core.context_processors.request Context Processor (in the TEMPLATE_CONTEXT_PROCESSORS tuple in settings.py).

(05 Nov '10, 23:22) ryans ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×28
×1

question asked: 05 Nov '10, 17:43

question was seen: 5,920 times

last updated: 05 Nov '10, 23:22

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM