All language subtitles for 011 All Post & Single Post Pages_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

So let's now work on that all posts page

in the views.py file that is that posts function here.

Now, there, we are doing something

very simple right now.

We're passing this all posts list,

to the all posts variable in the template.

Well, this all posts list is now an empty list,

and therefore this won't work anymore.

And stepping out I wanna get all the posts

from the database.

And of course that's fairly straightforward.

We can add all posts here and keep that name if we want to,

and then reach out to post, to the post module,

objects.all.

And this gives us all the posts.

Now we can also sort those in any way if we want to,

and actually I'll do that here.

I'll also order those by date

in a descending order to put the latest post first,

but that's of course optional.

But with that, we're now having a list

of all the posts from the database

and we're passing this to all posts in the template.

So now, if we save this and we reload this post page,

we see all free posts here.

Now for a single post,

if I click on that single post we get an error.

And that makes a lot of sense

because we're clearly failing to fetch that single post now.

So now we wanna work on post detail.

And there before, we basically worked with all posts

to find that one post with the correct slug.

Now, of course, that's not what we wanna do anymore.

I wanna get rid of that line of code here,

and we can also get rid of all posts all together here,

since we're not using that anymore.

We can get rid of that date, time imports

since we're not using the date function here anymore.

And we can get rid of that (indistinct) get date function

as well, to slim this file down.

And now back in post detail,

I still wanna get my identified post.

So this name, which I used here,

and now I wanna get a single post.

And you'll learn how that works.

We can use the post model, and then objects,

and then get, instead of all.

And this gets us a single post.

And here, we then can tell Django

how this post should be identified.

In this case that slug,

so that slug field in our post model,

the value there should be equal to the slug value

we're receiving here.

So slug on the right side is this argument,

slug on the left side is the name of that property,

of that attribute in our model.

Now, of course, this could fail

and therefore we could wrap this in a try except blog

to show a 404 page, if it does fail.

But I did show you a little shortcut,

which you can use instead,

where we import from Django shortcuts, not just render,

but also get object or 404.

And with that imported, we can get our post here,

simply by instead calling get, whoops!

Get object or 404,

pass in our post model here

to let Django know for which model it should find

an entry in the database.

And then our condition, which is slug equals slug.

With that we get the identified posts.

And if we now save this,

we should not get this error anymore

but instead a different error related to our image key

which again makes sense here,

because for posted detail

I'm also accessing post.image here,

that was correct before.

Now it's .image_name, so we should fix this.

And with this fixed, if we now reload,

that's looking better.

So now that is generally working

and we are outputting all that post data again.

But of course, we also have to tag

and we have to author the author model.

And I am outputting the author here for example.

I'm simply out putting post.author like this.

And because in the author model I added str,

this is actually I'm putting my full name, so that's good,

but maybe we wanna make this clickable, that name.

We wanna turn this into a link,

and when you click it, we open the mail client.

And maybe we also wanna show the tags of a post.

Let's say here on that post page, below that title.

And therefore these are the next steps

I wanna take in the next lectures.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.