Open tubaman opened 7 years ago
Here's a workaround but it's probably not the right fix.
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
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?
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.
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:mkvirtualenv testloginurl
pip install pinax-cli
pinax start account testloginurl
cd testloginurl
pip install -r requirements.txt
./manage.py migrate
./manage.py loaddata sites
add this import to
testloginurl/urls.py
:from django.contrib.auth.decorators import login_required
add this line to urlpatterns in
testloginurl/urls.py
:url(r"^protected$", login_required(TemplateView.as_view(template_name="homepage.html")), name="protected"),
./manage.py runserver
Go to http://localhost:8000/protected <- See the 404