Python will use solve the diamond problem through MRO[1], so it all depends
on the order you in which you mix your classes.


class MyBaseView(BaseDetailView):
    def get_context_data(self, *args, **kwargs):
        context = super(MyBaseView, self).get_context_data(*args, **kwargs)
        context['foo'] = 'MyView'

        return context

class MixinA(object):
    def get_context_data(self, *args, **kwargs):
        context = super(MixinA, self).get_context_data(*args, **kwargs)
        context['foo'] = 'MixinA'

        return context

class MixinB(object):
    def get_context_data(self, *args, **kwargs):
        context = super(MixinB, self).get_context_data(*args, **kwargs)
        context['foo'] = 'MixinB'

        return context


class SomeView(MixinA, MixinB, MyBaseView):
    pass

# ----

This is the correct solution. Try changing the order of the mixins in
SomeView to see the difference.


Cheers,
AT

[1] http://en.wikipedia.org/wiki/C3_linearization

On Tue, Jan 10, 2012 at 12:05 PM, jrief <jacob.r...@gmail.com> wrote:

> But the mixin plugins are not derived from django.views.generic.DetailView,
> otherwise the main app's DetailView would obtain a diamond shaped
> inheritance.
>
> And django.views.generic.detail.BaseDetailView.get calls get_context_dataonly 
> once, so I don't see how the plugins shall "deliver" their contexts.
>
> BTW, I found another solution.
>
> Cheers, J.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/FpplXSO5pBYJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to