MultipleObjectMixin and Pagination

130 views
Skip to first unread message

Andrew Ingram

unread,
Jun 30, 2011, 7:12:27 PM6/30/11
to Django developers
Hi All,

I've been working with Django's class-based views a fair bit recently,
specifically to create some additional ones (dealing with formsets
mostly). I've been trying to inherit as much of the existing
functionality as possible, but I've hit a bit of a snag.

I've a ModelFormSetMixin which extends MultipleObjectMixin, much like
how ModelFormMixin extends SingleObjectMixin in core.

I want to take advantage of the pagination that MultipleObjectMixin
provides, but I need it at the point of instantiating the FormSet.
Currently MultipleObjectMixin does all the pagination handling in
get_context_data which means I have to either re-implement a lot more
functionality than I'd like, or execute the pagination calculation
twice.

My ideal solution would be for MultipleObjectMixin to be changed to
have the pagination handled as early as possible so that I can take
advantage of it for free.

This is only one use case, but I'm sure there are more. I'm happy to
try and come up with a patch if there's some agreement on this.

The FormSet views I've developed can be seen here:
https://github.com/AndrewIngram/django-extra-views/blob/master/extra_views/formsets.py


Regards,
Andrew Ingram

Julien Phalip

unread,
Jun 30, 2011, 10:07:00 PM6/30/11
to Django developers
Hi Andrew,
> The FormSet views I've developed can be seen here:https://github.com/AndrewIngram/django-extra-views/blob/master/extra_...
>
> Regards,
> Andrew Ingram

I think your proposal makes sense and it's generally a good idea to
add more flexibility to class-based views (unless it over-complicates
the API, of course). It would definitely help assess the usefulness of
this if you posted a patch with a concrete test case, so feel free to
open a ticket. You might also be interested in ticket #16256, which is
looking at adding similar generic views to core. Perhaps this is
something you would like to contribute to based on your own experience
and use case?

https://code.djangoproject.com/ticket/16256

Regards,

Julien

Andrew Ingram

unread,
Jul 1, 2011, 6:52:55 AM7/1/11
to django-d...@googlegroups.com
Hi Julien,

I'm already involved on that ticket, the pagination issue is part of what's holding me back from contributing a patch. So I was looking to get some discussion about whether it's something that needs to be solved in core. In light of what you've said, I'm trying to think of a more straightforward test case that isn't tied to my ModelFormSetView.

- Andrew
Reply all
Reply to author
Forward
0 new messages