IN the Django docs they say this https://docs.djangoproject.com/en/dev/topics/auth/default/#user-objects
from django.contrib.auth.decorators import login_required
@login_required(login_url='/accounts/login/')
def my_view(request):
But how can i use login_required on class based view
@login_required
classMyCreateView(CreateView):
This gives error
'function' object has no attribute 'as_view'
You can do that in many ways like
https://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-class-based-views