Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
So how can we tweak the admin panel?
Well, in some aspects,
so when it comes to the individual fields to be precise,
we can typically do that in the models.
There, we have various extra options
which we can set like editable equals false,
which of course I don't wanna set here.
But we got some field specific options
which affect the forum where the field is rendered here
in our model when we work on the fields themselves.
But I'm pretty happy with what we have there.
There are some settings we can add here.
You can always dive in the official docs
to play around with all possible options.
But I wanna set some admin wide settings
to be precise settings which affect this page
where we see all the posts.
And for that go to admin.py and we add a new class here.
We add a post admin clause.
Now this clause name is up to you
but it should extend admin.model admin.
And then in there, we can add a couple of settings.
For example, we can add list filter to add a filter
on this posts page,
and to specify by which fields we should be able to filter.
And I want to be able to filter by author.
That is possible, even though it's a related field,
we can still filter by that.
And I want to be able to filter by date and by tags,
let's say.
These are the three fields
which make the most sense to me here.
Hence we set this to a tuple
where we simply add those field names.
So author, tag, and date, like this.
I also, as I said, want to display a couple of columns here
so that we don't just have these posts objects here
but instead we maybe show the title, the date, the author,
something like this.
Hence, I'll add list display which is the setting for that,
where we then add title, author,
and maybe date as a second value like this.
And as explained earlier in the course,
these field names which you specify here
of course, have to be exactly the same field names
you have in your model clause.
Now, with that, we need to make sure
that we also load this post admin clause so to say,
so when we register posts,
we now pass post admin as a second argument.
And with that, we can save this and get an error
because Django thankfully checks what I set up here.
And I just emphasized that
you have to use the exact same names.
Well, there is no field name tag, it's tags with an S.
So of course, it should be tags here as well.
So now we'll save this,
and thankfully Django has this check.
Now with this saved, if we reload here
we've got these columns and we can filter.
And we can automatically sort
by these columns here, by the way.
And with that, this already looks much nicer, I would say.
Now I also I wanna make sure though that when we add a post,
the slug is filled out automatically.
We can still override it manually then
but it should be pre-populated automatically.
And for this, we can add pre-populated fields.
And this takes a dictionary as a value
where we use the field that should be pre-populated
as a key, so in this case, the slug field,
using that field name here.
And then, as a value, we have a tuple
of all the fields that provides the values
for pre-populating that slug field,
in this case, just the title.
Again, save this.
And now if we reload here, when we add a new post,
if I type here, that slug gets filled out automatically.
And with that, I'll then add my third
and last dummy post here.
Nature at its best, like this.
Add the exert, like this.
Then grab the image name which is woods.jpg
and some content.
And here I'll again, take one paragraph,
add this here and get rid of these indentations.
And then just again,
if you want to repeat this multiple times like that.
And pick an author which again is me,
add a tag or multiple tags and save this.
So now we have all those posts added.
We have all that data added
and we are able to administer this as needed.
Now, I of course wanna make sure that if I go
to local host 8,000 to my blog here,
I no longer load that dummy data
from that all posts list here, but that instead now,
in our views, we query the database
with help of Django's bottles
and we display that model data
so that data coming from the database in our templates.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.