Daniel Wu
Daniel Wu

Reputation: 6003

django:How to get the response location(url) of HttpResponseRedirect

I am using django to dev a website. I need to get the url (location) from the redirect response, but can't find any method or attr.

Traceback (most recent call last):
  File "/opt/python27/lib/python2.7/site-packages/django/core/handlers/base.py", line 223, in get_response
    response = middleware_method(request, response)
  File "/opt/dbinabox/DBInBoxWeb/dbinabox/dbasrm/altus.py", line 16, in process_response
    print response.header
AttributeError: 'HttpResponseRedirect' object has no attribute 'header'

Upvotes: 2

Views: 1159

Answers (1)

neverwalkaloner
neverwalkaloner

Reputation: 47364

Try response.url. From the docs:

This read-only attribute represents the URL the response will redirect to (equivalent to the Location response header).

Upvotes: 4

Related Questions