I have the following hierarchy of classes:
class ProfileUpdateView( UpdateView, LoggerMixin ):
def get_context_data(self, **kwargs):
context = super(ProfileCreateView, self).get_context_data(**kwargs)
...
return context
UpdateView is in fact django.views.generic.UpdateView
class EventViewMixin(object):
template_name = ...
model = Event
form_class = ...
def get_success_url(self):
return self.success_url + str(self.object.id)
Class UpdateEventView mixes ProfileUpdateView and EventViewMixin
class UpdateEventView(ProfileUpdateView, EventViewMixin):
def form_valid(self, form):
...
return super(UpdateEventView, self).form_valid(form)
The problem in that for some reason the field “model=Event” is not visible to the framework when
it tries to use UpdateEventView. So I get the error:
UpdateEventView is missing a queryset. Define UpdateEventView.model, UpdateEventView.queryset, or override UpdateEventView.get_object().
What am I missing?
DISCLAIMER: I’m sort of a newbie to Python/Django.
So my question in sort of dumb …
The problem is in the order of the mixins:
must be replaced with:
This is because ProfileUpdateView has in its inheritance tree a field “model=None”,
and if ProfileUpdateView is on the first position in the that is the value that
will be considered. If EventViewMixin comes first, then the correct value is taken.