I'm looking for the easiest way to combine List and Create functionally with generic class views.
I want to have a page that has an item list and a form to add a new item on the bottom.
I thought that mixin architecture would allow to combine necessary classes but I had no luck yet.
This almost works:
class ResourceListView(ListView, BaseCreateView):
context_object_name = 'resources'
model = Resource
form_class = ResourceForm
But form
isn't accessible inside template and the thing crashes on invalid output (when form is valid, it's fine).
This may have to do with multiple inheritance but I'm not really into Python yet so it gets too confusing.
Is there a simple way to combine some of the mixins into a view-and-create View, or do I have to roll out my own?