#100DaysOfCode in Python Transcripts
Chapter: Days 85-87: Fullstack web apps made easy
Lecture: Adding filtering

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now what we want to do is go to our all_documents_form.
0:04 Which is hiding. Let's make some room here.
0:08 And when you type in this thing,
0:09 which is called TextBox Filter,
0:11 we want this to change.
0:12 So, we need to hook the change event down here.
0:14 Check this out. Change event.
0:17 And what we want to do is we want to basically set
0:20 the south.repeating_items
0:25 equal to filtered_docs.
0:28 We don't have this written yet.
0:29 We're going to write that.
0:30 And what we're going to do is I'm going to have a function
0:32 that'll take a document and turn it into text.
0:37 So, if I have this function, and I give it
0:38 one of these documents and it just says
0:41 convert into a string.
0:42 I can do a string search on that.
0:45 So, let's write this filtered documents
0:47 leveraging this little bit of code here.
0:52 Here we go.
0:53 So, what we're going to do is going to go to our TextBox Filter.
0:57 Grab the text.
0:58 And if they're not searching for anything,
1:00 we're going to return all the docs.
1:03 We're going to return all the documents.
1:08 Otherwise, we're going to create a list of documents
1:10 that if we converted to text and then lower case it,
1:13 and we do a find on the txt here,
1:16 then, then we're going to get it.
1:19 I guess we want to also say txt = txt.lower().
1:23 Like that.
1:24 In case you type something upper case
1:25 that wouldn't work well right there. Would it?
1:27 So, we' re just going to go through and say
1:28 literally as a string,
1:30 does that piece of text you typed in the filter,
1:32 does it appear in the document?
1:33 And then we're going to give that back right there.
1:36 Whew. Okay, and let's see if our filtering works.
1:41 So, here's our home. It's got all the documents.
1:44 Some of these, like the space photos and Higgs,
1:47 these are in the science category.
1:49 They have things like exotic materials.
1:52 This one is logging. So, this is logbook.
1:54 Let's just look where we talked about logbook.
1:59 Oh, filtered docs. What did I do wrong here?
2:01 Ah, self.
2:02 Self, self, self.filtered_docs.
2:05 So, let's try this again.
2:06 How about logbook.
2:08 Oh my goodness. Is that cool or what?
2:11 What about the ones that have to do with science?
2:15 Oh, I think the ones that have to do with science
2:16 might not be coming in there quite right.
2:18 This part right here, we have to get the name out.
2:22 Okay. One more time.
2:24 'Cause the category is actually a row. Right?
2:28 So, now let's try our science.
2:30 Those are the ones with that tag.
2:32 And about the ones with documentation. Those.
2:35 What about the ones have to do with datetime.
2:37 Which is what we talked about in Day 1.
2:39 datetime.
2:41 How about the word the?
2:42 That appears a lot.
2:43 How about RSS? Feedparser?
2:45 See how incredibly easy that is?
2:47 Watch how quick it is to go back and forth
2:49 between all of these.
2:50 Because we've downloaded this,
2:51 we're not hitting the server again.
2:53 It's just all running off of that cash thing.
2:56 Right there. Super cool.
2:57 So, we can come over and just search for RSS.
2:59 Bam, find it. Go pull out the details.
3:01 I guess the last thing for us to do
3:02 is put the details page in here.