Skip to content

Commit

Permalink
Added larger number of rows on listview page``:wq
Browse files Browse the repository at this point in the history
  • Loading branch information
shabda committed Feb 19, 2018
1 parent e204de5 commit 6d895a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Binary file added docs/icrease_row_count_to_one.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions docs/increase_row_count.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
How to show larger number of rows on listview page?
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

You have been asked to increase the number of heroes one can see on a single page to 250. (The default is 100). You can do this by::


@admin.register(Hero)
class HeroAdmin(admin.ModelAdmin, ExportCsvMixin):
...
list_per_page = 250

You can also set it to a smaller value. If we set it to 1 as :code:`list_per_page = 1` the admin looks like this.

.. image:: icrease_row_count_to_one.png
3 changes: 3 additions & 0 deletions heroes_and_monsters/entities/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def queryset(self, request, queryset):


class ExportCsvMixin:

def export_as_csv(self, request, queryset):

meta = self.model._meta
Expand All @@ -51,6 +52,8 @@ class HeroAdmin(admin.ModelAdmin, ExportCsvMixin):
list_filter = ("is_immortal", "category", "origin", IsVeryBenevolentFilter)
actions = ["mark_immortal"]

list_per_page = 1

def mark_immortal(self, request, queryset):
queryset.update(is_immortal=True)

Expand Down

0 comments on commit 6d895a8

Please sign in to comment.