djangosnippets.org: Latest snippets tagged with 'get-addr'https://djangosnippets.org/tags/get-addr/2012-12-13T17:17:26.955015-06:00Add get_addr() method to request object
2012-12-13T17:17:26.955015-06:00nikmolnarhttps://djangosnippets.org/snippets/2863/<p>I thought it would be useful to have a <code>get_addr()</code> method available on request objects, similar to the <code>get_host()</code> provided by Django. This middleware will add a <code>get_addr()</code> method to requests which uses the <code>X-Forwarded-For</code> header (useful if you're behind a proxy) if it's present and you have the <code>USE_X_FORWARDED_FOR …</code></p>
Freely redistributable