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

Add class based login required #117

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions en/authentication_authorization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ def post_new(request):
[...]
```

Or if you have a class based view:

```python
from django.views import View
from django.utils.decorators import method_decorator

class MyView(View):

@method_decorator(login_required)
def get(self, request, *args, **kwargs):
[...]
```

That's it! Now try to access `http://127.0.0.1:8000/post/new/`. Notice the difference?

> If you just got the empty form, you are probably still logged in from the chapter on the admin-interface. Go to `http://127.0.0.1:8000/admin/logout/` to log out, then go to `http://127.0.0.1:8000/post/new` again.
Expand Down
Loading