Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,150 --> 00:00:04,970
So, let's now start adding a form,
2
00:00:04,970 --> 00:00:09,650
a standard HTML form in this review.html file,
3
00:00:09,650 --> 00:00:11,710
and then thereafter, we're going to make sure
4
00:00:11,710 --> 00:00:15,620
that this template also gets rendered by our view,
5
00:00:15,620 --> 00:00:19,190
which it currently isn't and that we then also try
6
00:00:19,190 --> 00:00:21,390
to handle the form submission.
7
00:00:21,390 --> 00:00:24,350
But first of all, let's start with the form.
8
00:00:24,350 --> 00:00:27,300
For this, we create this form tag,
9
00:00:27,300 --> 00:00:31,380
we use the forum tag to default HTML form element
10
00:00:31,380 --> 00:00:35,620
and then in such a form we can output all the inputs
11
00:00:35,620 --> 00:00:37,260
we wanna have in that form.
12
00:00:37,260 --> 00:00:40,600
So, to start simple, we could add an input of type="text"
13
00:00:40,600 --> 00:00:43,833
let's say, the default HTML input element,
14
00:00:45,030 --> 00:00:48,400
and that would allow users to enter some text.
15
00:00:48,400 --> 00:00:52,950
Now we can give us input a label to give the user a hint
16
00:00:52,950 --> 00:00:55,960
about data the user should enter here
17
00:00:55,960 --> 00:00:59,120
and there we could expect the user name,
18
00:00:59,120 --> 00:01:03,810
so we say your name and it's also then considered
19
00:01:03,810 --> 00:01:08,670
a good practice for accessibility to connect label
20
00:01:08,670 --> 00:01:12,140
and input with special attributes in HTML,
21
00:01:12,140 --> 00:01:16,240
and give the label a four attribute where you point
22
00:01:16,240 --> 00:01:20,033
at the ID of another element to which this label is related.
23
00:01:20,980 --> 00:01:24,100
So here we could point at an element with ID name
24
00:01:24,100 --> 00:01:26,330
and then give this input the ID name
25
00:01:26,330 --> 00:01:29,290
so that for screen readers, for example,
26
00:01:29,290 --> 00:01:33,723
it's clear that this label refers to this input element.
27
00:01:35,560 --> 00:01:39,340
We also wanna give this input a name attribute.
28
00:01:39,340 --> 00:01:42,510
So, here I picked name as an ID name,
29
00:01:42,510 --> 00:01:44,063
I could've picked anything.
30
00:01:45,260 --> 00:01:48,370
Maybe let's go with username to make that less confusing,
31
00:01:48,370 --> 00:01:50,350
so, username it is here
32
00:01:50,350 --> 00:01:53,110
but then the name attribute is a special attribute.
33
00:01:53,110 --> 00:01:56,660
We can add to form elements like this input element,
34
00:01:56,660 --> 00:01:59,280
and this will then allow us to identify
35
00:01:59,280 --> 00:02:03,330
the submitted values once the form was submitted.
36
00:02:03,330 --> 00:02:06,620
And here I'll also use username as a value here
37
00:02:06,620 --> 00:02:09,750
but we could use a different value than we did here,
38
00:02:09,750 --> 00:02:11,500
It doesn't have to be the same one.
39
00:02:13,200 --> 00:02:15,998
Now, we have a form with one input element,
40
00:02:15,998 --> 00:02:19,260
we now also should add a button which can be
41
00:02:19,260 --> 00:02:21,313
pressed to submit the form.
42
00:02:22,460 --> 00:02:26,500
And here Alt + End gives a caption of send.
43
00:02:26,500 --> 00:02:30,480
Now this is all just HTML and if this is totally unclear
44
00:02:30,480 --> 00:02:34,180
you definitely should revise those HTML basics.
45
00:02:34,180 --> 00:02:36,863
We're just creating an HTML form here.
46
00:02:37,710 --> 00:02:40,030
Now, before we do anything else here,
47
00:02:40,030 --> 00:02:42,670
before we add any other configuration,
48
00:02:42,670 --> 00:02:46,740
let's make sure that this template also gets served.
49
00:02:46,740 --> 00:02:51,550
So in the views.py file, here in the review function,
50
00:02:51,550 --> 00:02:56,550
I'll return render and I accept my request here
51
00:02:56,800 --> 00:03:01,010
and pass that to render and then point at the template
52
00:03:01,010 --> 00:03:05,640
which I wanna render, which is reviews/review.html,
53
00:03:05,640 --> 00:03:08,260
so this template, which we just worked on
54
00:03:08,260 --> 00:03:10,280
and then save this file.
55
00:03:10,280 --> 00:03:14,670
And now with that we're almost ready to start our server.
56
00:03:14,670 --> 00:03:18,010
First, I just wanna go to my settings.py file
57
00:03:18,010 --> 00:03:22,480
and in there, I wanna add my app, my reviews app,
58
00:03:22,480 --> 00:03:25,383
so that Django will find the template here.
59
00:03:26,440 --> 00:03:28,930
That is important otherwise this app template
60
00:03:28,930 --> 00:03:32,477
will not be discovered by Django and this crashes
61
00:03:35,400 --> 00:03:38,963
because this should be path here, not include.
62
00:03:40,000 --> 00:03:44,970
So path in the urls.py file in the main feedback folder.
63
00:03:44,970 --> 00:03:47,770
Path and then only use include here.
64
00:03:47,770 --> 00:03:50,400
Oversight from my side, with that fixed,
65
00:03:50,400 --> 00:03:53,290
now I can start that development server.
66
00:03:53,290 --> 00:03:55,420
And if we now visit localhost:8000
67
00:03:55,420 --> 00:03:58,183
we get this very basic form here.
68
00:03:59,470 --> 00:04:03,580
Now it's lacking all styling, but it is a form.
69
00:04:03,580 --> 00:04:06,690
It also has this sent button and now watch the URL
70
00:04:08,030 --> 00:04:09,923
and see what happens if I click it.
71
00:04:10,900 --> 00:04:11,780
You see that?
72
00:04:11,780 --> 00:04:15,206
If I click send the URL changes and we got
73
00:04:15,206 --> 00:04:18,630
?username=nothing.
74
00:04:18,630 --> 00:04:20,950
Now, if I enter Max here and I click send
75
00:04:20,950 --> 00:04:25,410
the URL changes to ?username=Max.
76
00:04:25,410 --> 00:04:27,920
So it looks like the data I entered here
77
00:04:27,920 --> 00:04:29,673
is then added to the URL.
78
00:04:30,920 --> 00:04:33,510
So let's now explore whether that is what we want
79
00:04:33,510 --> 00:04:35,950
and let's talk about form submission
80
00:04:35,950 --> 00:04:38,423
and different HTTP methods.
6523
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.