Home > Mobile >  Overriding django admin pagination along with dynamic values
Overriding django admin pagination along with dynamic values

Time:12-06

I am working on a project, I have a requirement from my client he wants to implement a dynamic paginator in django admin panel. Requirement is when user input 10, ten record will display per page same for 20,30

is there any way to do it.

CodePudding user response:

See ModelAdmin.list_per_page. The default is 100 but you can change it to whatever you like.

class UserAdmin(admin.ModelAdmin):
    model = User
    list_per_page = 5 # No of records per page 
admin.site.register(UserAdmin)   

If you want to dynamically change it I'd assume you'd use an ajax with a GET for the page number otherwise you'd have to do a lot more and alter the default admin template used by django.

Check out this approach if it helps you .

  • Related