1 00:00:00,360 --> 00:00:04,229 You've probably noticed that the default for the list view is to show you whatever 2 00:00:04,229 --> 00:00:08,212 is in the string, or underscore underscore string underscore underscore method of 3 00:00:08,212 --> 00:00:11,740 your mode;, but it doesn't show you anything else. 4 00:00:11,740 --> 00:00:15,960 So for our courses list we only see the title of the course, 5 00:00:15,960 --> 00:00:19,640 because that's what we have set to return in the string method. 6 00:00:19,640 --> 00:00:23,680 But being able to see more fields from our models can be really helpful for 7 00:00:23,680 --> 00:00:25,310 a lot of reasons. 8 00:00:25,310 --> 00:00:27,660 It can give us more things to sort by. 9 00:00:27,660 --> 00:00:30,970 Date, or whether the course is live for example. 10 00:00:30,970 --> 00:00:34,005 It let's us see more information at a glance, and 11 00:00:34,005 --> 00:00:38,923 it can even help us edit information about our courses without having to navigate 12 00:00:38,923 --> 00:00:42,271 all the way to the detail view, saving us some clicks. 13 00:00:42,271 --> 00:00:46,050 For now, let's focus on adding some more fields to the list view. 14 00:00:47,920 --> 00:00:49,200 As I've said before, 15 00:00:49,200 --> 00:00:53,820 the great thing about the Django admin is how much it gives to you for free. 16 00:00:53,820 --> 00:00:58,190 To add more fields to our list view, we just need to tell the admin class for 17 00:00:58,190 --> 00:01:01,370 that model that we'd like to see those fields. 18 00:01:01,370 --> 00:01:04,360 So for courses, it might be nice to see, for 19 00:01:04,360 --> 00:01:07,520 example, the date the course was created. 20 00:01:07,520 --> 00:01:13,130 To see that, we just add the list_display variable, and 21 00:01:13,130 --> 00:01:18,460 make it a list, and then we add the names of the fields we want to see in order. 22 00:01:18,460 --> 00:01:22,734 So we know we wanna see the title because we already see that, but 23 00:01:22,734 --> 00:01:26,550 we wanna add the created_at field so we can see the date. 24 00:01:26,550 --> 00:01:28,775 So if we navigate to courses, 25 00:01:28,775 --> 00:01:33,048 now we see we can see the date that the course was created. 26 00:01:33,048 --> 00:01:37,967 And then this table became sortable too, so we can actually click on created at and 27 00:01:37,967 --> 00:01:41,957 we can sort In ascending order by the date of course was created, or 28 00:01:41,957 --> 00:01:44,617 we can sort in descending or reverse order. 29 00:01:44,617 --> 00:01:46,970 Or we can just put things back in alphabetical order, 30 00:01:46,970 --> 00:01:48,236 it doesn't really matter. 31 00:01:50,178 --> 00:01:52,810 Now let's add the is_live field two so 32 00:01:52,810 --> 00:01:56,572 we can see at a glance which courses are live on our site. 33 00:01:56,572 --> 00:02:01,628 So to do that we just add this other field into our list display. 34 00:02:04,935 --> 00:02:09,030 Now we can see this red X, which means that the course is not live, 35 00:02:09,030 --> 00:02:13,450 versus this green checkbox, which means the course is live. 36 00:02:13,450 --> 00:02:15,520 And again, we can sort by this too. 37 00:02:17,660 --> 00:02:18,370 Pretty neat? 38 00:02:19,610 --> 00:02:24,250 Remember that in order for the is_live field to do anything, you would need 39 00:02:24,250 --> 00:02:29,030 to add some code to your view to only bring back courses where is_live is true. 40 00:02:29,030 --> 00:02:32,000 I'll let you do that on your own. 41 00:02:32,000 --> 00:02:35,620 But isn't adding more fields to your list view simple? 42 00:02:35,620 --> 00:02:36,980 Before you try the next video, 43 00:02:36,980 --> 00:02:40,210 why don't you add some more fields to the other list views?