djangosnippets.org: Latest snippets posted by brianjaystanleyhttps://djangosnippets.org/users/brianjaystanley/2011-10-21T09:35:30.037659-05:00brianjaystanleyGet Client IP Behind Proxy
2011-10-21T09:35:30.037659-05:00brianjaystanleyhttps://djangosnippets.org/snippets/2575/<p>If your application server is behind a proxy, <code>request.META["REMOTE_ADDR"]</code> will likely return the proxy server's IP, not the client's IP. The proxy server will usually provide the client's IP in the <code>HTTP_X_FORWARDED_FOR</code> header. This util function checks both headers. I use it behind Amazon's Elastic Load Balancer (ELB).</p>
Freely redistributablePersistent Session Debugging with Django Debug Toolbar
2011-10-19T09:46:34.938629-05:00brianjaystanleyhttps://djangosnippets.org/snippets/2574/<p>When using <a href="https://github.com/django-debug-toolbar/django-debug-toolbar">django debug toolbar</a>, I like to be able to turn debugging on and off without having to edit my settings file. This callback makes that possible. Add <code>?debug=on</code> to the URL to turn debugging on. It will remain on in the current session until you turn it …</p>
Freely redistributable