Hello, friend, welcome back.
In a previous video, we successfully had to have this one is our username and there is our description.
Right.
And also we have updated our profile from here, if you update and then it to be redirected to our profile
piece.
So now I want to do I want to work with our post.
That means this user, if this user want to add some of the post, how can add this post in this video?
I will show that things with a live example.
So for adding this post, if you like.
No, I'd remove everything, OK?
I remove everything so that we don't need this any more bit.
And also I remove it.
Like if you go to a post into the post area, if you go to our model.
So for the post I have already declared all that our fields, our main field will be as emails and another
will be as a caption.
Right.
That means this user can post with our two of these filled up in this user can post some of the images
with the caption.
Right.
It will be just like our Instagram Cittadini Instagram.
You post some of the images, right.
So it'll be just like that same.
So here if you want to post it.
First of all, we have to create some of the form right across from one of the form.
We have to insert this our emails and the caption.
So if you want to do that work, then you have to do we have to create one of the forms right.
So opposed scene to the posterior.
I want to create one of the custom form.
I will open all the new file and I just name it as a format, OK, which will be as a form swordfight
soula the forms that file.
First of all, we have to load our Django form.
That means from that is in our Django and then from here I want to import our default class as a form
sorry.
That will be as a form.
Right.
So first of all, we have to load it.
And also I want to do want to get all that our data from our model that is from model and text as our
emails and the caption field.
So if you want to access it, first of all, you have to do have to load it.
So that is in our post and that is our models.
So now to do and load that is from our from our app underscore post.
That will be our post right from our app folder here.
I want to do our to get our models and from here on to import our post that means sorry, that is our
post.
Plus so from our model, I have already created our class as opposed to now I import our post class.
So now to do and to create the class for our form, I want to create the custom form I named as a class
so class and I named that our form name will be as a post form.
OK, that will be as a post form.
So that will be as a post from a name ID as a post and it will be inherited our forms sorry, it should
be noted our forms and then our model form.
That means the model form.
Right.
It should be in our model from perfect and then I want to do I want to add or all that feel.
So you going to get that field back without class.
So class will be as a middle class and the middle class area with this model, I want to go on to access
our model.
I want to access our post model.
So I have already loaded in put out this post model.
Right.
So that is our models and that is our table name as a post.
No, I already load out this class and here our model will be our poster from our post model.
I want to do I want to get all that our feel.
So here I name it our field.
OK, that means our fields, our fields will be right.
No one to want to get our two of this field.
I want to get our immense field, OK?
I want to get out in this field and also I want to get out another field as there should be as a caption.
OK, so from here I want to do I want to get out of this.
So I load our model.
So from our post model that is our fields, from our post model, I want to get our image field and
the caption field reckford I hope is very much clear to you.
So now I want to do I want to work in our view, that means, you know, ah, if you go to our app logging
into the app logging, if you go to our view so into the view area.
So that is our profile.
Right.
So into the profile area.
I want to load it.
So if you want to load it, first of all, you have to do we have to import it.
That means you have to put out this both opposed and that is our form.
So now I to do and to import it.
So here that is from from our post and from our post, I load our forms.
I have created one of the file as a forms and then I want to import and import our that means our apples
and that is our forms.
And from here I have created on the class of the post form.
So now to do and load it, that means I want to load our post from right field.
So with this class we can access, with this class we can access our two of these fields.
That is our image field and the caption Filaret so.
I want to turn to load our this form, so shall we be just like that, same before like that is our
users.
Here, here.
But I don't want to put that condition.
I want to put on the form that means which will be as a form.
OK, it's always a form.
And with this form, that will be our post.
That is our post from.
Right.
I have already included.
That means I have already improved our post from.
So now I loaded that piece.
I load our form and then I want to put that same condition that our request and request will be as a
matter right.
It will be checked that method as a post or not.
So shall we check it?
Because I want to load it some of the specific base.
So that will be our post.
And also after that, I take our form.
That means our form will be without this post from right.
That means our this post form.
So with this fourth form, we have to pass our request.
That means our request and then request will be as a post.
Right.
And also here I want to do and to work with our images.
That means the image.
So if you want to work with the images, as I told you before, here also we have to pass that our file
request.
Right.
So now I also want to do I want to pass our request or request will be as a files.
So request will be other files.
And then I want to check it.
That means if our form if our form is valid is underscore sorry, underscore valid.
So I want to check it if it's valid and then I don't want to first of all, check it like I take one
of the variable as a post.
And then we thought this form data, I save it.
And first of all, I don't want to make as a comet like a comet and we don't want to make it as a false
comet.
I want to make it as a false y.
I'm actually make it as a false because of all here we have to do we have to check it.
That means this user actually right now I'm already logging the Karzai.
Right.
So we have to do have to check it.
This user is appropriately our disk, this current user or not.
So here we have to do we have to check it.
So if we want to check it, it's pretty simple here.
We have to do if you go to our model, that means into the model area, you can see that is a clever
auto rights.
We have to check it out.
This auto is our current user unknot.
See, that is our authority.
If you want to access it, that is our name.
The relation with the posts with this post takes us out this author.
So with this post I want to do on Texas, our this author.
OK, I want Texas or this author and then I want to do it shall be Matute already to that.
That means our logging user, which users don't currently logging.
So that is our current user.
Right.
When our post our third and our current user will be equal, that means after that I don't want to save
this data.
So with this post I want to do and to save it, I hope is very much clear to your friend what exactly
the things I did on here.
So when this data will be saved after that, I wanted to return that we sound written with our SCDP
response.
That means when this user will be as safe our post, then it should be left to our better able to predict
it to our home base.
That means we the reverse and with a diverse area here and to do in the past our home.
So for the home I have already created that you are that this is our main project.
If we go to our main project, you are still here.
You can see that is our home.
You all I name it as a home.
I want to do want to pass it from here.
You can see they have no app name.
So for the reasons you can directly access our list name to no one to do and to access our list, you
should be directed to our home base.
So that is our form.
So now we have to do we have to pass this form, right.
We have to pass this form in our user dot is causing delays, is a little visible.
So better here after this.
OK, after this.
I want to deposit that within the parcel form.
Sorry it be as a single code that we form, I pass our form so now we can actually access our this form
in our user tortas.
Tamalpais Redfearn.
So that is our template.
That means in our app logging app logging and then that is our user dollars.
So that is the user datastream malaria here.
I want to do and the visible our form.
So how can do this work.
But I want to continue this process.
In our next video, I will show you that things with a live example.
So thanks for watching and I'll see you in the next video.