Django admin pagination question
hi i got a model in django admin working fine but it is listing all the object in only one page i would like to paginate then .. What do i need to add at my admin.py to get then paginate ... ?
heres my admin.py :
from cliente.models import Cliente
from django.contrib import admin
class ClienteAdmin(admin.ModelAdmin):
list_display = ('nome','bairro','endereco','telefone')
list_filter = ('bairro',)开发者_开发技巧
ordering = ('nome',)
search_fields = ('endereco',)
pass
admin.site.register(Cliente,ClienteAdmin)
See ModelAdmin.list_per_page. The default is 100
, but you can set it to a lower value.
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
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
精彩评论