Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Customizing the Django Admin Customizing the List View Customizing Attributes

Tatiana Vasilevskaya
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tatiana Vasilevskaya
Python Web Development Techdegree Graduate 28,600 Points

How to add a filter for a model method?

In the video we created a custom method time_to_complete on a course model and used it in admin list_display. Lacey suggested that we should add an extra list_filter using this new method. As I see it, we should create a custom filter, inheriting from django.contrib.admin.SimpleListFilter. But how then to implement a queryset method? How to filter a queryset based on time_to_complete?