[Mixins] - Order of the Mixins - Is it a bug?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Mixins] - Order of the Mixins - Is it a bug?

Vinnicyus Gracindo
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? or is it a bug?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMjWKi8LdUEwBnTfPX43x%3D5DWUam74dy-eVBof5%2BJmGOr1SLYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Mixins] - Order of the Mixins - Is it a bug?

Markus Holtermann
Hi Vinnicyus,

this is by design.

There's an interesting talk by Ana Balica on Mixins in Django: https://www.youtube.com/watch?v=rMn2wC0PuXw

/Markus

On Fri, Jun 15, 2018 at 02:31:42PM -0300, 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? or is it a bug?
>
>Thanks.
>
>--
>You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
>To post to this group, send email to [hidden email].
>Visit this group at https://groups.google.com/group/django-developers.
>To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMjWKi8LdUEwBnTfPX43x%3D5DWUam74dy-eVBof5%2BJmGOr1SLYQ%40mail.gmail.com.
>For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/20180615175002.t4wrac4ok5i47f52%40inel.local.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

[Mixins] - Order of the Mixins - Is it a bug?

jackotonye
In reply to this post by Vinnicyus Gracindo
By design mixins are applied in the order they are inherited.

`class A: pass`
`class B: pass`

```
    class C(A, B):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs) # This will call A.__init__() then B.__init__()
             


```

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/37bf280c-f471-4249-a91a-a1809076e367%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Mixins] - Order of the Mixins - Is it a bug?

Vinnicyus Gracindo
I understood now. Thank you so much. 

Em sex, 15 de jun de 2018 17:52, jackotonye <[hidden email]> escreveu:
By design mixins are applied in the order they are inherited.

`class A: pass`
`class B: pass`

```
    class C(A, B):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs) # This will call A.__init__() then B.__init__()



```

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/37bf280c-f471-4249-a91a-a1809076e367%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMjWKi8w5ja7mx9orCzSXsSqv8dx%2BN69LPswAyYk59A4wCO7_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.