Lorenzo Ang
Lorenzo Ang

Reputation: 1318

Print out Django Admin list results only

Is there a way to print out Django Admin's change_list page without including the filers? For example, if the page at 0.0.0.0:8000/admin/<app>/<object>/ shows the following

Complete page

I want to create a button that, when clicked, prints only this.

The only thing I need printed

I realize that I could just remove list_filter but for some pages, I need them to be there

Upvotes: 1

Views: 614

Answers (1)

GwynBleidD
GwynBleidD

Reputation: 20569

You can overwrite get_list_filter method in your ModelAdmin subclass and define logic here that can disable filters just by returning empty list or tuple. For example:

class MyModelAdmin(admin.ModelAdmin):
    list_filter = ['class']

    def get_list_filter(self, request):
        if request.GET.get('no_filters') == '1':
            return []
        return super(MyModelAdmin, self).get_list_filter(request)

Upvotes: 1

Related Questions