Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Customizing the Django Admin Customizing the List View Test: Custom Filters

Add the lookups method to your TopicListFilter. Remember that this method takes self, request, and model_admin as argume

Add the lookups method to your TopicListFilter. Remember that this method takes self, request, and model_admin as arguments, and that you need to return a tuple of tuples.

For the tuples, add "Python", "Ruby", and "Java" as options and values. See the documentation if you get lost.

help

courses/admin.py
from django.contrib import admin

from . import models

class TextInline(admin.StackedInline):
    model = models.Text

class QuizInline(admin.StackedInline):
    model = models.Quiz

class AnswerInline(admin.StackedInline):
    model = models.Answer

class TopicListFilter(admin.SimpleListFilter):
    title = 'topic'
    parameter_name = 'topic'
    def lookups(self, request, model_admin):
        return (('Python',_('Python','Python','Ruby')), ('Ruby',_('Python','Ruby','Java')), ('Java',_('Python','Ruby','Java')))

    # ENTER YOUR CODE HERE.

class CourseAdmin(admin.ModelAdmin):
    inlines = [TextInline, QuizInline]

    list_filter = ['created_at', 'is_live']

admin.site.register(models.Course, CourseAdmin)

1 Answer

def lookups(self, request, model_admin):
        return (('Python',('Python')), ('Ruby',('Ruby')), ('Java',('Java')))

only one for one.