Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

account - 404 when going to a @login_required page #47

Open
tubaman opened this issue Jan 23, 2017 · 4 comments
Open

account - 404 when going to a @login_required page #47

tubaman opened this issue Jan 23, 2017 · 4 comments

Comments

@tubaman
Copy link

tubaman commented Jan 23, 2017

When using the account starter app, if I hit a @login_required page I get a 404. It looks like it's trying to redirect me to /accounts/login/ which doesn't exist. Here's how to recreate the bug:

  1. mkvirtualenv testloginurl

  2. pip install pinax-cli

  3. pinax start account testloginurl

  4. cd testloginurl

  5. pip install -r requirements.txt

  6. ./manage.py migrate

  7. ./manage.py loaddata sites

  8. add this import to testloginurl/urls.py: from django.contrib.auth.decorators import login_required

  9. add this line to urlpatterns in testloginurl/urls.py: url(r"^protected$", login_required(TemplateView.as_view(template_name="homepage.html")), name="protected"),

  10. ./manage.py runserver

  11. Go to http://localhost:8000/protected <- See the 404

@tubaman
Copy link
Author

tubaman commented Jan 23, 2017

Here's a workaround but it's probably not the right fix.

@tubaman
Copy link
Author

tubaman commented Jan 23, 2017

Ok, it seems I need to use account.decorators.login_required instead of django.contrib.auth.decorators.login_required. I figured this out by digging through the code. I couldn't find it in the docs

@tubaman
Copy link
Author

tubaman commented Jan 24, 2017

I've create a pull request against the docs. Is there a way we can get rid of this login_decorator and use Django's built-in instead?

@paltman
Copy link
Member

paltman commented Apr 16, 2017

I believe that @brosner's version in DUA handles some extra things like handing next but I'm not completely sure without studying the differences in code. I do know there is likely a very good reason why DUA is shipping with it's own rather than using the built-in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants