LoginRequiredMixin
works great on other class based views. Also the Form Tools FormPreview
works fine. But when I try to use both together, then the LoginRequiredMixin
gets ignored.
This is even the case if I use the most basic example from form tools and the Django documentation.
Two things I found strange (but this does not necessary be the reason):
.as_view()
, which is off standard again.Is this a bug? What can I do?
FormPreview
is not a generic class based view, so you can't use it with mixins like LoginRequiredMixin
.
You can use the login_required
decorator when you include the form preview instance in your URL patterns:
from django.contrib.auth.decorators import login_required
url_patterns = [
url(r'^form-handler/$', login_required(MyFormPreview(SomeModelForm))),
]