This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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+

Installation

Install from PyPI

pip install django-paginated-modelformset

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.

Release History

Release History

This version
History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-paginated-modelformset-0.0.2.tar.gz (4.4 kB) Copy SHA256 Checksum SHA256 Source Jan 9, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting