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.

Thiago Oliveria
137 PointsThe queryset() method needs to call filter() on its 'queryset' argument.
i believe my code is right , i can't understand the message of the error:
"The queryset() method needs to call filter() on its 'queryset' argument." because , i use queryset argument in method with filter , but keep show the error i look in documentation the django and looks like right ...
Can someone show me when is my error ? or this is a bug ?
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, admin_model):
return (
('Python', 'Python'),
('Ruby', 'Ruby'),
('Java', 'Java'),
)
def queryset(self, request, queryset):
if self.value() == 'Python':
return self.queryset.filter(title__contains='Python')
if self.value() == 'Ruby':
return self.queryset.filter(title__contains='Ruby')
if self.value() == 'Java':
return self.queryset.filter(title__contains='Java')
class CourseAdmin(admin.ModelAdmin):
inlines = [TextInline, QuizInline]
list_filter = ['created_at', 'is_live']
admin.site.register(models.Course, CourseAdmin)
1 Answer

Chris Freeman
Treehouse Moderator 68,082 PointsThe error is not in the code specifically. The challenge is looking for lowercase words. Also, the self.
prefix should not be used in this case since queryset
is not an attribute of the class, but rather an argument to the method.
def queryset(self, request, queryset):
if self.value() == 'python':
return queryset.filter(title__contains='python')
if self.value() == 'ruby':
return queryset.filter(title__contains='ruby')
if self.value() == 'java':
return queryset.filter(title__contains='java')