Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django model overview: show more than 100 items?

In one of the models overview panel, after I filter the items by month, I have to select them all and then create a document with information regarding them (kind of like a monthly report). This is a problem when one month has more than 100 items as Django paginates the filtering results.

Is there a way to increase the number of items shown from 100 to 400 or select all the items from the filtering result?

Selecting all the items from one page, creating a document, going to the next, creating another, etc, then merging the documents isn't an option.

like image 775
yoshi Avatar asked Feb 01 '10 10:02

yoshi


People also ask

What is Inlines in Django?

django-inline-actions provides a handy templatetag render_inline_action_fields , which adds these information as hidden fields to a form. As the action does not know that an intermediate form is used, we have to include some special handling.

What is proxy model in Django?

Proxy models allow us to change the Python behavior of a model without changing the database. vehicles/models.py. from django.db import models. class Car(models.Model): vin = models.CharField(max_length=17)

Is Django's admin interface customizable if yes then how?

You can customize the Django admin to do almost anything you want. In this tutorial, you learned how to: Register your object models with the Django admin. Add attributes as columns in the change list.

What is through in Django models?

The through attribute/field is the way you customize the intermediary table, the one that Django creates itself, that one is what the through field is changing.


2 Answers

See http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_per_page

In your ModelAdmin definition, set list_per_page:

class MyModelAdmin(admin.ModelAdmin):
    list_per_page = 400

I believe you can also add the all GET parameter to your query (ie, add ?all to the end of your url), but that only works if you have less than 200 items, and this limit is hardcoded in the admin. Therefore it's only useful if you have more than list_per_page (100) and less than 200 items, but the admin will offer you a link for this anyway when this is the case.

like image 142
Will Hardy Avatar answered Sep 20 '22 12:09

Will Hardy


If you're talking about admin, see this.

ModelAdmin.list_per_page
like image 26
Dmitry Shevchenko Avatar answered Sep 22 '22 12:09

Dmitry Shevchenko