Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit display rows in Admin Panel Django

I have Admin.py as follows .

from django.contrib import admin
from do.models import *

class NewsAdmin(admin.ModelAdmin):
    list_display=['time','message']

 admin.site.register(do_model,NewsAdmin)

I while i go to the admin panel and go to the do_models , it is showing me huge lots of data . I dont want to see all data from the beginning date , is it possible that i can limit data till 20 or 30 lines of data and rest of data should not be shown like paginating so that it load easily . Kindly suggest .

like image 739
Rock Hill Avatar asked Jun 09 '17 02:06

Rock Hill


People also ask

Can we customize Django admin panel?

The Django admin is a powerful built-in tool giving you the ability to create, update, and delete objects in your database using a web interface. You can customize the Django admin to do almost anything you want.

How do I restrict access to parts of Django admin?

Django admin allows access to users marked as is_staff=True . To disable a user from being able to access the admin, you should set is_staff=False . This holds true even if the user is a superuser. is_superuser=True .

What is Fieldsets in Django admin?

It's just a way for you to be able to group the fields on a Model Admin Page. Just implement the example in the documentation and it should become apparent for you.

How use Django admin panel?

To login to the site, open the /admin URL (e.g. http://127.0.0.1:8000/admin ) and enter your new superuser userid and password credentials (you'll be redirected to the login page, and then back to the /admin URL after you've entered your details).


1 Answers

 class NewsAdmin(admin.ModelAdmin):
    list_display=['time','message']
    list_per_page = 400

 admin.site.register(do_model,NewsAdmin)

you can use list_per_page to limit the number of rows shown in a single page

like image 73
Exprator Avatar answered Nov 07 '22 20:11

Exprator