Django Admin Inline Paginator
The "Django Admin Inline Paginator" is a Python library designed to add pagination to inline forms within the Django administration interface. The latest version, 0.4.0, was released in April 2023. The original project is currently seeking maintainers, with development seemingly inactive, and a community-maintained fork (`django-admin-inline-paginator-plus`) has emerged to continue development and add new features.
Warnings
- breaking The original `django-admin-inline-paginator` project is no longer actively maintained by its original author, who is looking for new maintainers. Its last release was in April 2023. An actively maintained fork, `django-admin-inline-paginator-plus`, exists and offers new features, including AJAX pagination and broader compatibility with modern Django and Python versions. Users should consider using the `plus` fork for ongoing support and new features.
- gotcha The `django-admin-inline-paginator` package was last updated in April 2023 and officially requires Python >=3.3. However, newer versions of Django (e.g., Django 4.x, 5.x) require Python 3.8+ or higher. Using this original package with recent Django versions may lead to compatibility issues or unexpected behavior due to API changes over time.
- gotcha The `django-admin-inline-paginator` library implements pagination by reloading the entire admin page for each page navigation, which can impact user experience, especially with many inlines or slow connections. It does not support AJAX-based pagination.
- gotcha When dealing with a very large number of inline fields (even if paginated), Django's `DATA_UPLOAD_MAX_NUMBER_FIELDS` setting might be exceeded during form submission, leading to "TooManyFieldsSent" errors. This is a Django core limitation, but relevant when using inline pagination.
Install
-
pip install django-admin-inline-paginator
Imports
- TabularInlinePaginated
from django_admin_inline_paginator.admin import TabularInlinePaginated
- StackedInlinePaginated
from django_admin_inline_paginator.admin import StackedInlinePaginated
Quickstart
from django.contrib import admin
from django.db import models
# Assuming you have a model named `YourModel` and another `ModelWithFK`
# linked by a ForeignKey from ModelWithFK to YourModel.
# Example Models:
# class YourModel(models.Model):
# name = models.CharField(max_length=100)
# class ModelWithFK(models.Model):
# your_model = models.ForeignKey(YourModel, on_delete=models.CASCADE)
# name = models.CharField(max_length=100)
# 1. Add 'django_admin_inline_paginator' to INSTALLED_APPS in settings.py
# INSTALLED_APPS = [
# ...,
# 'django_admin_inline_paginator',
# ...
# ]
# 2. Create your model inline using TabularInlinePaginated
from django_admin_inline_paginator.admin import TabularInlinePaginated
class ModelWithFKAdminInline(TabularInlinePaginated):
model = 'ModelWithFK' # Replace with your actual FK model
fields = ('name',)
per_page = 5 # Number of items per page
# pagination_key = 'page-model' # Optional: required for multiple paginated inlines
# 3. Register your main model admin and use the inline
@admin.register('YourModel') # Replace with your actual main model
class YourModelAdmin(admin.ModelAdmin):
model = 'YourModel'
fields = ('name',)
inlines = (ModelWithFKAdminInline,)