Search code examples
pythondjangoadmindjango-formsdjango-pagination

How to add a pagination "go to page" form set to Django admin on a ModelAdmin form?


Here's the gist of my desired scenario:

I've got the standard Django pagination going in the admin site. What I'd like to do is let a user enter a number into a text input that corresponds to some page number. The user presses enter or clicks a button. Results for the page number entered are then shown.

Note:

  • I'm using Django 1.2.3 with Python 2.65
  • I'm modifying a ModelForm someone else created for our admin site.

Any ideas, suggestions, and/or comments greatly appreciated!

Thank you,

Michaux


Solution

  • Every pagination system I have come across including the standard Django pagination uses GET parameters for rendering a page.

    So, providing a form to get the page number of the page to be displayed is the simplest thing you can do with html forms.

    <form>
    
        <input type="text" name="page">
        <input type="submit">
    
    </form>
    

    To include this, you might want to override the corresponding admin template.