On 16/06/2018 3:29 AM, Vinnicyus Gracindo wrote:
Hi. I beat my brains out trying to find out why my cbv was not working with LoginRequiredMixin.
I found the order of the mixins in the inheritance:
It works: class UserListView(LoginRequiredMixin, ListView)
Doesn't work: class UserListView(ListView, LoginRequiredMixin)

Is that how it was designed?

Yes. See ...

https://docs.djangoproject.com/en/1.11/topics/auth/default/#django.contrib.auth.mixins.LoginRequiredMixin

... where the LoginRequiredMixin is positioned ahead of the View class. Or in your case the ListView class. For success it relies on Python method resolution order (MRO) see ...

https://www.python.org/download/releases/2.3/mro/  (introduced in Python 2.3)

You may be aware of http://ccbv.co.uk/ with its very comprehensive documentation of Django CBVs. Well worth a visit if you haven't seen it.

Mike

or is it a bug?

Thanks.
--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMjWKi9RFwDWSnNU%3Dv16-bXx%2BjEvMOfnVnWnhrnFnFzrWsMsyQ%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAMjWKi9RFwDWSnNU%3Dv16-bXx%2BjEvMOfnVnWnhrnFnFzrWsMsyQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9e840556-2f34-f5bc-48f7-35f780e402a0%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to