pinax / pinax-starter-projects

Pinax Starter Projects
MIT License
81 stars 39 forks source link

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

Open tubaman opened 7 years ago

tubaman commented 7 years ago

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 commented 7 years ago

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

tubaman commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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.