On 29-8-2012 4:44, Rainy wrote: > When I use CBVs, I nearly always end up needing to mix different types in > the same view, e.g. detail view and list view, list view and modelform > view, etc. I really like CBVs but I feel this is the one shortcoming that I > constantly run into that makes CBVs much less flexible and helpful than > they could be.
What are your real world cases for this? If you combine several models to make up a page, you should consider writing your own mixins that inherit only from ContextMixin and implement get_context_data() to add the extra information. For example: class OnSaleMixin(ContextMixin) : on_sale_queryset = Products.objects.filter(on_sale=True) def get_context_data(self, **kwargs) : context = { 'on_sale_list': self.on_sale_queryset } context.update(kwargs) return super(OnSaleMixin, self).get_context_data( **context) class ProductList(ListView, OnSaleMixin) : model = Products -- Melvyn Sopacua -- 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.