Django : Testing if the page has redirected to the desired url

后端 未结 4 1913
无人及你
无人及你 2020-12-03 12:58

In my django app, I have an authentication system. So, If I do not log in and try to access some profile\'s personal info, I get redirected to a login page.

Now, I

4条回答
  •  北海茫月
    2020-12-03 13:36

    response['Location'] doesn't exist in 1.9. Use this instead:

    response = self.client.get('/myprofile/data/some_id/', follow=True)
    last_url, status_code = response.redirect_chain[-1]
    print(last_url)
    

提交回复
热议问题