An attempt to add pagination to Django Model Formsets.
Project description
An attempt to add pagination to Django Model Formsets.
Requirements
Python 2.6+ or Python 3
Django 1.6+
Usage
from django.forms.models import modelformset_factory from paginated_modelformset import PaginatedModelFormSet from myapp.models import MyModel MyModelFormSet = modelformset_factory(MyModel, formset=PaginatedModelFormSet) # In addition to standard arguments, provide a number of items per page and a page number. formset = MyModelFormSet(per_page=25, page_num=1)
PaginatedModelFormSet uses the same Paginator class that is used for standard pagination. A Page object is accessible as a page attribute of the formset and you can use it in templates like this:
<div class="pagination"> <span class="step-links"> {% if formset.page.has_previous %} <a href="?page={{ formset.page.previous_page_number }}">previous</a> {% endif %} <span class="current"> Page {{ formset.page.number }} of {{ formset.page.paginator.num_pages }}. </span> {% if formset.page.has_next %} <a href="?page={{ formset.page.next_page_number }}">next</a> {% endif %} </span> </div>
Alternatives
See this StackOverflow question for an alternative solution.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-paginated-modelformset-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 701a56c732134b6359a8e6697ef19f14c30bbf8cd8882aeb7b4ed9214bca0060 |
|
MD5 | 91cb5029f51f9b16f811cf1af69591c1 |
|
BLAKE2b-256 | 3284ccb458789f7b3cd033b9da8ad28b2772e14786f271d3b2a8634c449a0b1e |