26👍
We should inherit the LoginRequiredMixin
first. because python will consider the method dispatch
from the first inherited class(in this case).
from django.contrib.auth.mixins import LoginRequiredMixin
class ArtWorkCreate(LoginRequiredMixin, CreateView):
login_url = '/index/'
redirect_field_name = 'index'
model = ArtWork
5👍
Just Define a Login url on the settings.py file
(also remove the login url on the class)
#settings.py
LOGIN_URL = 'login'
0👍
login_url is URL that users who don’t pass the test/authentication will be redirected to.
redirect_field_name attribute should be set to URL the user should be redirected to after a successful login.
- Django annotating with a first element of a related queryset
- Django reverse error: NoReverseMatch
- Logging formatters in django
Source:stackexchange.com