53👍
See ModelAdmin.list_per_page. The default is 100
, but you can set it to a lower value.
30👍
Here I take example of 5 records per page, you can change according to your requirement:
class UserAdmin(admin.ModelAdmin):
model = User
list_per_page = 5 # No of records per page
4👍
Here I take the example of 10 records per page, you can change according to your requirement:
class CK_Sub_CategoryAdmin(admin.ModelAdmin):
list_display=('Sub_Category_Name','Parent_Category_Name')
search_fields=('Sub_Category_Name','Parent_Category_Name')
list_filter=('Sub_Category_Name','SC_Published_Date')
actions=[make_inactive,make_active]
list_per_page=10 #record 10 per page
- Django: default language i18n
- Changing password in Django Admin
- ProgrammingError: relation "django_session" does not exist
1👍
You can set list_per_page to list the specific number of items on each paginated Change List page. By default, 100
is set to list_per_page
.
And, you can also set list_max_show_all to show or hide Show all link on each paginated Change List page. By default, 200
is set to list_max_show_all
. *Show all link appears if list_max_show_all
value is more than or equal to total items while Show all link disappears if list_max_show_all
value is less than total items.
For example, there is Person
model below:
# "models.py"
class Person(models.Model):
name = models.CharField(max_length=20)
def __str__(self):
return self.name
And, there is Person
admin below:
# "admin.py"
@admin.register(Person)
class PersonAdmin(admin.ModelAdmin):
pass
Then, all 7
persons are listed as shown below:
Now, I set list_per_page = 4
to Person
admin as shown below:
# "admin.py"
@admin.register(Person)
class PersonAdmin(admin.ModelAdmin):
list_per_page = 4 # Here
Then, 4
persons are listed on the 1st page as shown below:
And, 3
persons are listed on the 2nd page as shown below:
Next, I click on Show all link as shown below:
Then, all 7
persons are listed as shown below:
Next, I set list_max_show_all = 6
to Person
admin as shown below:
# "admin.py"
@admin.register(Person)
class PersonAdmin(admin.ModelAdmin):
list_per_page = 4
list_max_show_all = 6 # Here
Then, Show all link disappears as shown below because list_max_show_all
value 6
is less than the total persons 7
:
- Use a django built in filter in code (outside of a template)
- How to combine django plus gevent the basics?
- Change default Django REST Framework home page title
- How to test (using unittest) the HTML output of a Django view?
- How can I disable a model field in a django form