All language subtitles for 004 Author Model & one-to-many_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
en English
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
fa Persian Download
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 besides the post model, which of course

is the most important model for this website

we also wanna have authors.

We wanna have an author model

and we wanna set it up as the find on this slide,

hence, back in the models.py file,

we can add class, author, and extend models.model

And here I now I wanna set up a first name,

which is a CharField with a max length of,

let's say 100

and basically repeat this for the last name as well.

And then let's also add the email address.

And for this,

we could add another CharField

since the email address is just text in the end,

but conveniently Django has an email field,

which we can use instead.

And again, if we search for email field here

to read more about that,

we see that in the end, this is a CharField,

which just automatically validates the input

and checks if it is a valid email address.

So when we later used the admin panel,

we'll automatically get email address validation,

which of course is very convenient.

And if we would try to save data in the database,

which is not an email address,

if we would try to save such data through that model,

it would fail.

So, this is now my author model,

and therefore, it's now time for our first relation.

For this One-to-Many relation,

which we have between author and post.

Now you'll learnt that you can set up

One-to-Many relations

by adding such a foreign key field.

So, here I wanna go to my post,

and add the author field here,

and set these two models or, and key.

And that then allows me

to point at the related model,

which in this case is the author.

This sets up this relation.

Now we also wanna add on delete

to make sure how Django and SQL should behave here.

If we delete an author which was assigned to a post,

and in that case, we probably don't wanna

delete the entire post.

So I will just say models, set, null,

to set the field,

the author field to null,

if we delete a related author,

I also wanna make sure that

when we use the inverse of the relation for querying,

we don't have to work with post underscore set,

but with just posts

therefore I'll set up the related name here

and set this to posts

so that we'll be able to pick an author

and then query for the posts of that author

if we wanted to do that anywhere.

And that's the author model added,

and the first relation set up.

Let's now work on the last model

and the last relation.

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