Hey, welcome back.
We're going to continue working on the admin interface.
So far we only have this here to customize the admin interface sides, meaning that we can add some
more fields here, more columns to show some more data about the users in the summary view here.
And we can also add some functionality here, some features where the admins can filter the data by
specific fields.
So to do all that you need to go back to the admin.py file which is inside job application and between
the import statements and the registration of the form, you want to create a class form admin.
So I give this this name because the module is called form and it makes sense to call this form admin.
This inherits from admin dot model admin.
So this is a class designed to create admin interfaces.
So basically we are modifying the default model admin.
Now this class gets some specific variables such as list display.
So if you give this variable you should give it exactly as you see the name here list underscore display
with lowercase letters.
So if Django finds this variable in this class, then what Django will do is it will display all these
columns of the database table, such as first underscore name, last underscore name.
Whatever you want to be displayed in this view here.
You want to add those names in here.
So these names should reflect these ones here, right?
First name, last name, email, date, occupation.
So these are the field names in the form model.
Right?
So let me go and refresh.
And oh, that didn't change anything because oh, we forgot to add the form admin to register it right,
because we created a class.
But Django doesn't know what you mean by this class, so we need to add it to the register function.
So you need to add the form.
First form is the model from models.py and then comma form admin.
Right, that's it.
Let's refresh.
This time we see this view.
So now we have customized it.
We want to see the first name, last name, email.
So first name.
Last name.
Email.
Search fields.
Another variable.
If you define this variable and you can then provide like again, a tuple.
Like this.
Let's go and refresh.
So this time we have this search bar displayed here so you can type in something here and search for
those fields that we defined in here.
Next.
The list filter.
Let's try this time date and occupation.
Let's go back to refresh and we've got this filter here.
So in here you can filter by the date.
So if you go to John, for example, John specified a date when they are available for the new job.
So with that, if you go back to forms with that, you can filter only those job candidates who are,
for example, available in the last seven days or this month or this year.
So don't confuse this with the date when the entry was submitted by the user.
To do that, you need to change the database.
You need to add another field where you record the date of the registration of a record of a submission.
So this is another thing here.
And of course, by occupation.
So if you click on student, you will see only the students here as an admin.
Right.
Let's go back to the code.
You can also order.
The data by specifying a string such as, let's say, first name.
And don't forget to put a comma here so that this is actually a tuple.
Refresh.
Oh, we have the filter turned on.
So click that to remove the filter.
And now we see our deeds is the first one followed by John because it starts with an A and you can also
order in reverse.
To do that, you should write a minus just before first name.
So inside the quotes and you go here, refresh.
And now the order of the items has changed.
So John is the first one.
And lastly, if you go to one of these entries here and you can modify all these fields as an admin,
but if you want to make one field read only, you can do that by specifying a read only underscore fields
variable.
So let's say occupation.
Only occupation and the comma and go here, refresh.
And now you can not change the student.
And yes, that's how you work with the admin interfaces.
So these are basically all you need to know about creating admin interfaces.
So I hope this is useful.
I'll see you in the next video.