Django redirects to my sign-in page with next=the correct page, each time

I set s breakpoint in the view for /diagram/diagram-editor/<int:diagram_id> and it is never hit. Instead, Django is erroneously redirecting to:

http://127.0.0.1:8000/sign-in?next=/diagram/diagram-editor/a4a84b132bc845a090b381ef71747c2c

Which results in a 404 Page not found.

There is nothing unusual about and I’ve checked my URLs. What information can I give you such that we can fix this bug?

I can say that /sign-in isn’t a valid URL even, because /accounts/sign-in is the correct one. I don’t see the text /sign-in anywhere in my project.

A MWE is not possible because the project is too big, and if I made an MWE, it wouldn’t have the bug. This is something I did such as uninstalling and app improperly, but I can’t figure it out. Is there anyway to get a better trace of Django?

If Django is doing that redirect, then you have somthing causing it. It could be:

  • Middleware
  • Decorator on the view function
  • Mixin on a view class

In looking for sign-in, don’t restrict your search to just your project. Examine your entire virtual environment to find where it’s coming from.

1 Like