Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot paginate using ModelFormSetView #261

Closed
yannish8 opened this issue Mar 13, 2023 · 4 comments
Closed

Cannot paginate using ModelFormSetView #261

yannish8 opened this issue Mar 13, 2023 · 4 comments

Comments

@yannish8
Copy link

The following code does not return 10 results as expected - all results from the model are returned instead. This is problematic when the table contains a lot of results:

class TestFormSetView(ModelFormSetView):
    model = TestModel
    fields = ["test_field"]
    template_name = "test_output.html"
    paginate_by = 10

I see that there is a PR open to handle pagination but it's from September 2021 and there's not been any activity on it for some time. I'm currently testing that PR locally but thought I'd create an issue to see if there are any alternatives

@powderflask
Copy link

@AndrewIngram - I built a suite of CBVs on top of ModelFormSetView that integrate django-tables2 and django-filter. Includes a ModelFormsetTable view, FilteredModelFormset view, and FilteredModelFormsetTable view.

These views leave it to django-tables2 to handle pagination. They also greatly simplify (i.e. virtually eliminate) template logic for rendering such tabular formset views.

I'm considering options to release these and it makes sense to bundle them with django-extra-views, perhaps as a contrib package with a fmft (filtered-model-formset-table) module? Wondering if you'd be open to such a pull request, and if so if you have thoughts or preferences for the package structure?

@sdolemelipone
Copy link
Collaborator

Hi @powderflask, that does sound interesting although I'd be wary of making django-tables2 and django-filter dependencies of this package. Also it would increase the testing complexity as changes to those packages could break this one.

What if you added your code as a new section in the documentation for this project, rather than as a contrib package?

I use django-tables2 and django-filter in combination like this too, I'd be interested to see how the pagination works.

@powderflask
Copy link

@sdolemelipone that makes sense. Nice offer re: documentation, seems like a logical level to connect the 2 projects.
Here's the Filtered-Model-Formset-Table views package: https://github.com/powderflask/django-fmft
There's no docs yet - just doing the packaging and documentation now.

I'll propose a docs PR for extra-views once I get my own FMFT docs in order. Maybe a new section after List Views named Integrations, with a sub-section for Filtered Model Formset Table Views?

re: pagination - it simply uses the tables2 paginated queryset as the formset data, otherwise lets tables2 handle pagination.

@powderflask
Copy link

For anyone interested...
Basic docs are up: https://django-fmft.readthedocs.io/en/latest/
And package is now on pipy: https://pypi.org/project/django-fmft/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants