Skip to content

Commit 4a80446

Browse files
committed
Session 10 - you searched for text in CBV
1 parent a3cb85e commit 4a80446

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/community_db/views.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ def get_queryset(self):
5050
# Return the queryset now that we have filtered it (if we need to)
5151
return queryset
5252

53+
def get_context_data(self, **kwargs):
54+
# Get the default context that would be generated
55+
context = super().get_context_data(**kwargs)
56+
57+
# Get the search text and add it to the context
58+
search_text = self.request.GET.get("search")
59+
context["search_text"] = search_text
60+
61+
# Return our new context
62+
return context
63+
5364

5465
class PersonDetailView(DetailView):
5566
model = Person

0 commit comments

Comments
 (0)