For class based views in material.frontend.views I would like to redirect to the login_url if the user is not authenticated (anonymous). LoginRequiredMixin should help us here, correct?
from django.contrib.auth.mixins import LoginRequiredMixin
from material.frontend.views import ModelViewSet
from . import models
class MyModelViewSet(LoginRequiredMixin, ModelViewSet):
model = models.MyModel
All objects in MyModel need permissions. Anonymous users get no permissions
When I request the detail view of the ViewSet as an anonymous user, the 403 Page is shown.
Since the the user is not authenticated we get from detail.get_object a PermissionDenied.
Instead we'd expect/want a redirection to the login_url.
For class based views in material.frontend.views I would like to redirect to the login_url if the user is not authenticated (anonymous).
LoginRequiredMixin
should help us here, correct?All objects in
MyModel
need permissions. Anonymous users get no permissionsWhen I request the detail view of the ViewSet as an anonymous user, the 403 Page is shown. Since the the user is not authenticated we get from detail.get_object a PermissionDenied.
Instead we'd expect/want a redirection to the login_url.
Any clue what is going wrong here!