Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,040 --> 00:00:05,060
So let's start working with that data.
2
00:00:05,060 --> 00:00:07,070
And for that, I'll start with the authors
3
00:00:07,070 --> 00:00:09,140
and add a new author.
4
00:00:09,140 --> 00:00:12,423
And I'll add myself here, Maximilian,
5
00:00:13,540 --> 00:00:15,190
Schwarzmuller.
6
00:00:15,190 --> 00:00:18,090
And we got this built in validation, which we saw before.
7
00:00:18,090 --> 00:00:20,350
So if I try to save this here I get an error
8
00:00:20,350 --> 00:00:22,540
is because email address is required,
9
00:00:22,540 --> 00:00:25,970
and here it's also validating if that is an email address
10
00:00:25,970 --> 00:00:28,020
and it tells me if it's not,
11
00:00:28,020 --> 00:00:32,159
because I did set this special field type here,
12
00:00:32,159 --> 00:00:36,760
for post, for author email address has this email field,
13
00:00:36,760 --> 00:00:39,830
that's why we get this email address validation.
14
00:00:39,830 --> 00:00:42,470
But now if I do add some dummy email address here,
15
00:00:42,470 --> 00:00:43,933
I can save this author.
16
00:00:44,800 --> 00:00:48,810
Now I'm not too happy with the output of the author here.
17
00:00:48,810 --> 00:00:51,390
So of course you learn how you can tweak this.
18
00:00:51,390 --> 00:00:55,143
You can override this underscore underscore str,
19
00:00:56,630 --> 00:01:01,230
method here, in the author model or in all models.
20
00:01:01,230 --> 00:01:03,480
And this allows you to change,
21
00:01:03,480 --> 00:01:05,970
how it's represented as a string.
22
00:01:05,970 --> 00:01:09,850
How objects based on that model are represented as a string.
23
00:01:09,850 --> 00:01:14,170
And here we could return first name and last them combined,
24
00:01:14,170 --> 00:01:16,560
and we can again create such a helper method,
25
00:01:16,560 --> 00:01:19,960
as I all did it before in one of the core sections,
26
00:01:19,960 --> 00:01:22,550
we can add a full name,
27
00:01:22,550 --> 00:01:23,940
method here,
28
00:01:23,940 --> 00:01:26,860
where I returned an F string,
29
00:01:26,860 --> 00:01:29,830
where I have self first name, widespace,
30
00:01:32,090 --> 00:01:35,360
self, last name, and then the str method,
31
00:01:35,360 --> 00:01:38,730
we just return the result of calling
32
00:01:38,730 --> 00:01:40,853
self dot full name,
33
00:01:41,850 --> 00:01:43,110
like this.
34
00:01:43,110 --> 00:01:45,900
That's something we can and that is something we did before
35
00:01:45,900 --> 00:01:47,173
in this course as well.
36
00:01:48,240 --> 00:01:50,950
Now, if I save this and reload here,
37
00:01:50,950 --> 00:01:52,993
I have this nicer presentation.
38
00:01:55,080 --> 00:01:58,610
I also wanna work on my posts and I wanna add a new post.
39
00:01:58,610 --> 00:01:59,770
But before we do that,
40
00:01:59,770 --> 00:02:02,550
I want to add a couple of tags to work with.
41
00:02:02,550 --> 00:02:05,730
So here in tags, I will add a,
42
00:02:05,730 --> 00:02:07,300
featured
43
00:02:07,300 --> 00:02:11,310
tag and save this, and add another new tag,
44
00:02:11,310 --> 00:02:15,370
where I say new and save and add another,
45
00:02:15,370 --> 00:02:19,660
and add a hot tag. So that now I got three tags.
46
00:02:19,660 --> 00:02:22,100
And again, I'm not really happy
47
00:02:22,100 --> 00:02:24,370
with how this is represented here?
48
00:02:24,370 --> 00:02:26,780
So of course we can also go to the tag model
49
00:02:26,780 --> 00:02:29,180
and override this str,
50
00:02:29,180 --> 00:02:30,780
special
51
00:02:30,780 --> 00:02:31,733
method here,
52
00:02:32,620 --> 00:02:36,010
to make sure that we return self-taught caption.
53
00:02:36,010 --> 00:02:38,370
So simply the caption stored in the tag
54
00:02:38,370 --> 00:02:42,960
as a string representation for the overall model object.
55
00:02:42,960 --> 00:02:45,773
So now if you reload, we see this.
56
00:02:46,910 --> 00:02:48,950
Now let's work on the posts,
57
00:02:48,950 --> 00:02:51,890
and of course there will face a similar problem
58
00:02:51,890 --> 00:02:53,290
with how it's presented,
59
00:02:53,290 --> 00:02:57,420
but here I'll not add the str method, but instead there,
60
00:02:57,420 --> 00:03:01,560
I later want to tweak our admin panel a little bit
61
00:03:01,560 --> 00:03:04,370
as we all learned it early in the course.
62
00:03:04,370 --> 00:03:06,940
But first of all, let's add a post here
63
00:03:06,940 --> 00:03:08,770
and let's give it a title.
64
00:03:08,770 --> 00:03:10,700
And for this all simply copy one
65
00:03:10,700 --> 00:03:14,210
of my dummy posts titles I created before.
66
00:03:14,210 --> 00:03:17,010
So the data which we have in views.py.
67
00:03:17,010 --> 00:03:21,470
I'll take mountain hiking as a title, and as an excerpt,
68
00:03:21,470 --> 00:03:25,920
I'll take this text here, let's see if it's too long,
69
00:03:25,920 --> 00:03:27,620
maybe we can use it.
70
00:03:27,620 --> 00:03:31,090
As an image name I'll pick this image name
71
00:03:31,090 --> 00:03:32,263
which I used before,
72
00:03:33,680 --> 00:03:34,683
like this.
73
00:03:35,650 --> 00:03:37,090
And as a slug,
74
00:03:37,090 --> 00:03:39,950
it would be nice if that would be auto populated
75
00:03:39,950 --> 00:03:42,730
and that's there also something we'll add soon.
76
00:03:42,730 --> 00:03:44,990
For the moment, I'll manually write it
77
00:03:44,990 --> 00:03:47,543
and copy that slug which I used before.
78
00:03:48,740 --> 00:03:51,530
Now for the content, I wanna to take this content
79
00:03:51,530 --> 00:03:53,540
which I have here, this dummy text
80
00:03:53,540 --> 00:03:55,470
and add to this here.
81
00:03:55,470 --> 00:03:58,273
And whilst I'm here, I'll fix the line breaks,
82
00:03:59,890 --> 00:04:01,520
so that there are some line breaks,
83
00:04:01,520 --> 00:04:04,623
but I don't have this strange indentation.
84
00:04:05,880 --> 00:04:07,490
So,
85
00:04:07,490 --> 00:04:08,973
make it like this,
86
00:04:11,300 --> 00:04:15,210
remove this and just copy this one more time
87
00:04:15,210 --> 00:04:18,589
and get rid of all those paragraphs down there.
88
00:04:18,589 --> 00:04:20,253
So that I have this text here,
89
00:04:21,190 --> 00:04:23,830
and then as an author, I'll assign myself,
90
00:04:23,830 --> 00:04:26,180
and I'll make this featured and hot,
91
00:04:26,180 --> 00:04:27,980
and you can select multiple values here
92
00:04:27,980 --> 00:04:31,903
by holding down command on Mac iOS or control on windows.
93
00:04:33,340 --> 00:04:35,090
And then let's click save here.
94
00:04:35,090 --> 00:04:37,523
So now this post was saved.
95
00:04:39,160 --> 00:04:41,810
Now I will add a second post immediately,
96
00:04:41,810 --> 00:04:44,790
and again, steal my data from here.
97
00:04:44,790 --> 00:04:48,990
Programming is great, and insert this here,
98
00:04:48,990 --> 00:04:50,863
and add this excerpt,
99
00:04:52,750 --> 00:04:56,810
like this. and of course also insert the image name
100
00:04:56,810 --> 00:04:59,253
which I used here, which is this one.
101
00:05:00,240 --> 00:05:03,650
And at the slug, it's still not automatically created
102
00:05:03,650 --> 00:05:06,733
So I'll temporarily still add it myself.
103
00:05:07,910 --> 00:05:11,920
And for the content, I again will use this dummy content,
104
00:05:11,920 --> 00:05:14,180
copy this text, paste it in there,
105
00:05:14,180 --> 00:05:18,360
get rid of the line breaks or these strange indentations
106
00:05:18,360 --> 00:05:20,433
and just repeat this here.
107
00:05:21,550 --> 00:05:23,830
And again, I'll also select myself again,
108
00:05:23,830 --> 00:05:27,100
since I'm the only author and make this new.
109
00:05:27,100 --> 00:05:28,440
We could assign more tags,
110
00:05:28,440 --> 00:05:30,253
but I'll just assign one tag here.
111
00:05:31,090 --> 00:05:34,350
Now we have two posts and we can add a third post,
112
00:05:34,350 --> 00:05:38,110
but before we do that, I wanna tweak the admin panel.
113
00:05:38,110 --> 00:05:41,840
I wanna make sure that here we got multiple columns,
114
00:05:41,840 --> 00:05:44,640
that we can filter here on the right.
115
00:05:44,640 --> 00:05:48,430
And I also want to make sure that when we edit a post,
116
00:05:48,430 --> 00:05:51,470
the slug is auto populated.
117
00:05:51,470 --> 00:05:54,760
And these of course are all things we already did before.
118
00:05:54,760 --> 00:05:56,380
I just want to implement them again
119
00:05:56,380 --> 00:05:58,350
so that we again see them in action.
120
00:05:58,350 --> 00:06:00,223
And we practiced what we learned.
9232
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.