background top icon
background center wave icon
background filled rhombus icon
background two lines icon
background stroke rhombus icon

Download "Изучение Django 3 / Урок #10 - Динамически изменяемые страницы"

input logo icon
Table of contents
|

Table of contents

0:00
Начало
0:58
Создание класса для обработки шаблона
3:37
Отслеживание URL адреса
5:45
Создание HTML шаблона
8:27
Добавление ссылок на статьи
10:45
Корректный «title» для статей
Video tags
|

Video tags

sql
mysql
создание сайта
django веб сайт
django 3
python
django
джанго
django уроки
django tutorial
python уроки
уроки python
django python
django уроки для начинающих
изучение django
видеокурс
уроки
курс
django python уроки
Subtitles
|

Subtitles

subtitles menu arrow
  • ruRussian
Download
00:00:01
will create dynamic pages to
00:00:03
display each individual article
00:00:05
but first I want to recommend the site and
00:00:08
these Prager dot com on this site you
00:00:10
will find the homework code and a lot of
00:00:12
other useful information the link to
00:00:14
this lesson on the site will be in the description of
00:00:16
this video
00:00:17
during this lesson we will create a
00:00:19
page that will be available at the
00:00:21
following url address for example newsflash
00:00:24
and then dynamic parameters for example
00:00:26
one two three four and so on and
00:00:29
depending on these dynamic
00:00:31
parameters and on this page we will
00:00:33
show information either about the first
00:00:35
article either about the second article or about the
00:00:37
third article and so on, that is, we
00:00:40
will have only one page,
00:00:42
we will have this constantly
00:00:44
changing legal address and depending on
00:00:46
what parameter will be
00:00:48
substituted here, what number will be
00:00:50
substituted here depending on this on this
00:00:52
page we will show this or that
00:00:54
article,
00:00:55
well, let’s implement this now
00:00:57
before we start writing it all out with you,
00:00:59
I want to draw your attention to the
00:01:00
fact that earlier I said that in django
00:01:03
there are two ways to manipulate
00:01:06
records that are in the database the
00:01:08
first way is when we can
00:01:10
simply create our own function and write something like this in it, something like this,
00:01:14
and the second way is that we can create
00:01:17
classes based on the predefined
00:01:20
classes that are in django, and
00:01:22
we have already discussed the first method
00:01:24
yes, we have already created our own function and
00:01:26
now it’s time to consider the second
00:01:28
method, that is, we will create a class here and
00:01:30
it will inherit everything from the
00:01:33
built-in django classes and inside
00:01:35
this class we will also write
00:01:38
some characteristics and thereby
00:01:40
create this dynamic page to
00:01:42
display each a separate article, so I
00:01:45
suggest let’s initially
00:01:48
just create a class here inside the views policy, then we’ll learn to
00:01:50
track the url address, but then we’ll
00:01:52
create the html template itself. To
00:01:55
create a class, we initially need
00:01:57
to import the built-in class, so we’ll go from Jung,
00:02:00
then from views, then from the folder generic
00:02:04
we import a class
00:02:06
called detailsview, just
00:02:09
based on this class you can create a
00:02:11
cat page that
00:02:12
will constantly change
00:02:13
depending on the parameter that will
00:02:16
tell the address and we are doing exactly this with
00:02:19
you now and let’s do it
00:02:21
somewhere here we are Let’s just write down the
00:02:23
creation of a new class, this will be
00:02:25
our new class, the class itself can be called
00:02:28
whatever you want, for example, let’s use the
00:02:30
sound as news detail view, its name
00:02:33
can be anything, the main thing is that you
00:02:34
must indicate that it inherits everything from the
00:02:36
detail view class,
00:02:38
here inside the class we with you we
00:02:41
simply indicate some
00:02:42
characteristics, firstly, I must
00:02:44
say that we will work with a
00:02:46
model called articles,
00:02:48
so here I indicate Olya’s model and
00:02:50
indicate that we are working specifically with the
00:02:52
articles model,
00:02:53
then we also need to specify the
00:02:54
template name variable here and in it we
00:02:56
simply indicate which template will
00:02:58
process the page here, as it were, I
00:03:00
will have a template that will be
00:03:02
called detailsview a little later we will
00:03:05
create this template ourselves, and
00:03:08
additionally I will also indicate the
00:03:10
context variable object name here, this is
00:03:12
just, well, this is just essentially like
00:03:14
the name of the key by which we will
00:03:16
transfer the very specific record
00:03:19
inside the template, well, you can come
00:03:21
up with a name absolutely anything I want, for
00:03:23
example, let’s indicate the name as a post,
00:03:25
or maybe let’s do better as an
00:03:27
article, it will be more logical and probably
00:03:29
the name, that is, it’s just like a key
00:03:31
for which we are passing a specific
00:03:34
object inside the template, but
00:03:36
we’ll get to know all of this a little later. Now let’s
00:03:38
go to the urals policy. pine and here we
00:03:41
will create a new tracking url address,
00:03:44
what needs to be done here,
00:03:46
firstly, you and I must track a
00:03:48
url address that will begin
00:03:49
with the word news and here we specifically in
00:03:53
this file do not need to register this word news
00:03:55
here we are, as it were, registered that
00:03:57
the part that already comes after this word,
00:03:59
well, here we can’t just write
00:04:02
that we will cut off Yuri’s
00:04:03
address, for example 123 or something like that,
00:04:06
we need to indicate that we are tracking
00:04:08
a certain dynamic parameter, and to
00:04:10
indicate that we will cut off a dynamic
00:04:12
parameter we must open and close
00:04:14
angle brackets inside them we indicate
00:04:16
that we are tracking a dynamic parameter
00:04:18
which is an integer for us and
00:04:20
then, separated by a colon, we must name
00:04:22
this itself in pairs,
00:04:24
i.e. let's use it on sounds and those are
00:04:26
the primaries and well, you will run the primary key,
00:04:29
this is quite logical and the normal name
00:04:31
will be for this parameter, here is an important
00:04:33
point, do not put any spaces, otherwise there
00:04:35
will be errors, nothing will work,
00:04:37
so we just indicated that we are
00:04:39
tracking how the url -address that
00:04:41
should start with the word news here we
00:04:44
just didn’t register it with you because
00:04:45
in the main file and duralumin cm it’s already
00:04:47
kind of written down, and then we just
00:04:49
wrote here that we’ll cut off some
00:04:50
dynamic parameters 12 and so on,
00:04:53
something like this in this spirit, and now we
00:04:56
need to say the following: if we
00:04:59
go to such a url address,
00:05:01
then we must call this time
00:05:03
not any method, not any
00:05:05
function, but we must call the class,
00:05:07
which we call news dll
00:05:09
view, in order to indicate this to us, we also
00:05:12
refer to and kill the file, and here we
00:05:14
simply refer to cnews d t l the
00:05:17
only difference when calling a function and
00:05:19
calling a class is that here at the end
00:05:21
we still need to refer to a
00:05:23
method
00:05:24
called s- view if we
00:05:26
haven’t done this here, see, and don’t turn
00:05:29
to the method in the fall, then we will
00:05:30
get an error, and also since
00:05:33
we are already working with and named me
00:05:35
Yuri addresses, then let us also
00:05:37
indicate here some certain name and the name will be like
00:05:40
news dtl for example this is the name for
00:05:43
this Yuri, we will
00:05:44
indicate the addresses here, now we
00:05:46
need to create a new template,
00:05:49
let's just copy the
00:05:51
name and template folders here,
00:05:53
we will just create a new template and a new
00:05:56
file for the family. eat they say, well, so we
00:05:58
created it inside this file,
00:06:00
let's paste all this code that
00:06:02
we had in the news home file,
00:06:03
we just copy it from there and
00:06:05
paste it here and let's maybe you'll
00:06:08
delete the entire lower part here for now and
00:06:10
just write it down a new code, see
00:06:13
the h1 tag, I want to see not just a certain
00:06:16
post, but I want to see the title of this
00:06:18
article to which we have switched, in order for me to
00:06:20
do this, I need to
00:06:22
refer to the article object here, this is
00:06:25
the name we put here before m, that is, we ourselves
00:06:27
indicated it here in the class we
00:06:28
indicated that we are passing an object by the
00:06:30
name article
00:06:31
here I simply refer to this as a
00:06:33
title and just like before
00:06:35
through a dot I just
00:06:37
6 to the desired pain which I want to display
00:06:39
I want to display the title
00:06:41
but here I want to display the title of
00:06:42
the article here so I turn to the article and
00:06:44
turn to the title,
00:06:46
and it will be displayed here. I would also
00:06:48
like to display the full text of the article.
00:06:50
For this, I also write down what when
00:06:52
turning to the article and here and here I already
00:06:55
display, for example, the full text, and
00:06:57
in addition, perhaps by the way, let us do
00:06:59
this let's do it a little higher, that is, right here
00:07:02
at the top, I would also like to display the date of publication of the
00:07:05
article itself, mark the profession, cut off
00:07:07
and display simply d, that is, the date
00:07:10
of publication of the article,
00:07:11
let's now
00:07:13
see what we got, we'll just
00:07:15
go to the URL for now, for example
00:07:17
news is one and we can notice that everything
00:07:20
was processed correctly for us, that is, we
00:07:22
are displayed here the title of the article
00:07:24
here we are displayed yes, well, here we
00:07:27
are shown as if the full text of the article itself,
00:07:29
that is, with the help of classes you can
00:07:32
actually do even more in a simple
00:07:34
format to implement
00:07:36
the functionality we need, that is, here we
00:07:38
were still thinking about this
00:07:41
sql query itself, well, we were kind of thinking
00:07:43
about what methods should be
00:07:45
used here, but here everyone quite
00:07:47
simply indicated a certain model,
00:07:49
it seemed like a template and indicated using
00:07:52
using what kind of name do we
00:07:54
transfer the data inside this
00:07:56
template itself and there is no need to register anything else here, the
00:07:59
same predefined classes
00:08:01
exist and to display all records,
00:08:04
for example, there is a class
00:08:05
called something like seven and on its
00:08:07
basis you can, well, you can practically
00:08:09
register the same thing just point out that we
00:08:11
are using list view and based on the family
00:08:14
we will create a template inside of
00:08:16
which we will display all the records
00:08:18
from a certain table and there are many such
00:08:20
pre-installed classes, for
00:08:22
now let’s
00:08:23
just focus on the dtl view
00:08:26
now next to each article we will
00:08:28
additionally let’s display a
00:08:30
button when clicked on which we will
00:08:32
go to the URL address for example news 1
00:08:35
news2 news 3 and so on, that is, it
00:08:37
will be a button for more details and
00:08:39
reading of an article, and to
00:08:42
do this we need to go to the
00:08:43
news template here under the output with the announcement,
00:08:47
let's create a new link while we wo
00:08:49
n't enter the legal address,
00:08:51
let's just add here the
00:08:53
bottom loaf warning style, that is,
00:08:55
this is the style from bootstrap and here it will be
00:08:57
written, for example, read in more detail
00:09:00
for example and that's all, and now you need to specify
00:09:03
Yuri abyss himself here we are the url we will
00:09:06
indicate the address using named links,
00:09:08
that is, we are addressing you real and
00:09:10
then we need to address
00:09:12
this url address, which is called
00:09:13
news dtl, so let’s give it here
00:09:16
as a name and write it down, but
00:09:18
news detail is the url address that
00:09:21
also accepts certain dynamic
00:09:23
parameters and this dynamic parameter
00:09:25
we need to pass it here,
00:09:27
in order to pass a dynamic parameter
00:09:29
simply separated by a space, we indicate here the
00:09:32
value that we will
00:09:34
pass, I can simply indicate
00:09:35
the number two here and we will always have
00:09:37
dynamic parameters substituted, this is this, this is
00:09:40
this number, but this is not exactly
00:09:42
what I need, I need to pass on the
00:09:44
ID of each specific entry, and
00:09:46
to do this I turn to lm in the same
00:09:49
way as here we displayed
00:09:51
the title or announcement, also I turn to
00:09:53
lm and turn to such a pain as ID,
00:09:56
here it is in the migration files, you
00:09:59
can even open their migration file, we have
00:10:00
always created a separate
00:10:02
field here called ID,
00:10:04
this is an automatically created field and it
00:10:07
essentially represents a certain
00:10:08
serial number of each specific
00:10:10
record and it is this field we will
00:10:13
pass as a parameter to the legal address, that
00:10:16
is, for example, yes, for the first article
00:10:18
it will be the value 1 for the 2nd article it
00:10:20
will be the value 2, so then if we
00:10:22
now save this and update
00:10:24
the page, then we have buttons, when you
00:10:26
click on the button we go to well so
00:10:29
initially, for example, for our last
00:10:31
article, I go to the Yuri address news 4
00:10:34
and here it is displayed as if this is
00:10:35
my article, let’s also
00:10:38
go for example to this article and we
00:10:40
go to the url address news 3 and here it
00:10:42
is displayed as if the third is here is
00:10:45
the article, all I propose to do in
00:10:47
this video is let’s change the
00:10:49
python for each of these pages
00:10:52
because now where we haven’t gone to the title, it’s the
00:10:54
same everywhere here, it’s not
00:10:56
very
00:10:57
cool, well, in fact,
00:10:59
we don’t have to change the title you will need to
00:11:01
perform any additional actions,
00:11:04
all we need to do is this
00:11:06
here you will forget,
00:11:07
we need to transfer the title in the
00:11:10
article format.
00:11:12
python, in general, all this
00:11:14
was a very, very easy solution, well, where have
00:11:16
n’t we gone now? 8 languages ​​are written here that are
00:11:19
suitable for you, here we have, I’ll
00:11:21
forget about another article, then this
00:11:22
Chinese thing will be different, but in general, then
00:11:24
now these pages look pretty
00:11:26
good,
00:11:27
of course, here you can still work
00:11:28
on the styles, but the main thing is that all the
00:11:30
functional part of us is completely
00:11:32
recreated and you can already work with the styles, you
00:11:34
can simply add them at any
00:11:36
appropriate moment, well, that’s
00:11:38
all for me, so subscribe to the channel and
00:11:40
join VKontakte group and also
00:11:42
go to the ID Prager website.
00:11:44
all links will be in the description of this
00:11:45
video, see you soon

Description:

Мы уже умеем выводить все статьи на одной странице. Теперь мы создадим одну динамическую страницу для отображения различных статей. Статьи будут показываться в зависимости от параметра взятого из URL. 🔫 Полезные ссылки: 1) Урок на сайте itProger: https://itproger.com/course/django/10 ⏰ Тайм коды: 00:00 - Начало 00:58 - Создание класса для обработки шаблона 03:37 - Отслеживание URL адреса 05:45 - Создание HTML шаблона 08:27 - Добавление ссылок на статьи 10:45 - Корректный «title» для статей ✔ Сообщество программистов: https://itproger.com/ ✔ ------------- Вступай в группу Вк - https://vk.com/prog_life 🚀 Группа FaceBook - https://goo.gl/XW0aaP Инстаграм itProger: https://www.instagram.com/itproger_official/ Instagram: https://www.instagram.com/gosha_dudar/ Telegram: https://t.me/itProger_official Twitter - https://twitter.com/GoshaDudar - Уроки от #itProger 👨🏼‍💻 - Все уроки по хештегу #itprogerLessons

Preparing download options

popular icon
Popular
hd icon
HD video
audio icon
Only sound
total icon
All
* — If the video is playing in a new tab, go to it, then right-click on the video and select "Save video as..."
** — Link intended for online playback in specialized players

Questions about downloading video

mobile menu iconHow can I download "Изучение Django 3 / Урок #10 - Динамически изменяемые страницы" video?mobile menu icon

  • http://unidownloader.com/ website is the best way to download a video or a separate audio track if you want to do without installing programs and extensions.

  • The UDL Helper extension is a convenient button that is seamlessly integrated into YouTube, Instagram and OK.ru sites for fast content download.

  • UDL Client program (for Windows) is the most powerful solution that supports more than 900 websites, social networks and video hosting sites, as well as any video quality that is available in the source.

  • UDL Lite is a really convenient way to access a website from your mobile device. With its help, you can easily download videos directly to your smartphone.

mobile menu iconWhich format of "Изучение Django 3 / Урок #10 - Динамически изменяемые страницы" video should I choose?mobile menu icon

  • The best quality formats are FullHD (1080p), 2K (1440p), 4K (2160p) and 8K (4320p). The higher the resolution of your screen, the higher the video quality should be. However, there are other factors to consider: download speed, amount of free space, and device performance during playback.

mobile menu iconWhy does my computer freeze when loading a "Изучение Django 3 / Урок #10 - Динамически изменяемые страницы" video?mobile menu icon

  • The browser/computer should not freeze completely! If this happens, please report it with a link to the video. Sometimes videos cannot be downloaded directly in a suitable format, so we have added the ability to convert the file to the desired format. In some cases, this process may actively use computer resources.

mobile menu iconHow can I download "Изучение Django 3 / Урок #10 - Динамически изменяемые страницы" video to my phone?mobile menu icon

  • You can download a video to your smartphone using the website or the PWA application UDL Lite. It is also possible to send a download link via QR code using the UDL Helper extension.

mobile menu iconHow can I download an audio track (music) to MP3 "Изучение Django 3 / Урок #10 - Динамически изменяемые страницы"?mobile menu icon

  • The most convenient way is to use the UDL Client program, which supports converting video to MP3 format. In some cases, MP3 can also be downloaded through the UDL Helper extension.

mobile menu iconHow can I save a frame from a video "Изучение Django 3 / Урок #10 - Динамически изменяемые страницы"?mobile menu icon

  • This feature is available in the UDL Helper extension. Make sure that "Show the video snapshot button" is checked in the settings. A camera icon should appear in the lower right corner of the player to the left of the "Settings" icon. When you click on it, the current frame from the video will be saved to your computer in JPEG format.

mobile menu iconWhat's the price of all this stuff?mobile menu icon

  • It costs nothing. Our services are absolutely free for all users. There are no PRO subscriptions, no restrictions on the number or maximum length of downloaded videos.