Okay.
Once we have our application here, we will need to do a few things here.
So first thing first I will go back to here.
What we've done is we've created here.
And it said to us that we need to create a put a virtual environment name there.
So if I will go back here and you see virtual environment, it's under path here.
So what we need to do is we need to provide that virtual environment.
The name.
So it was movie writer virtual env.
That was the name that we had it there.
So if I click here you see it is added there.
So basically we need to tell what is the virtual environment for our application.
The next thing that we need to do is we need to put a patch on our for our code.
So the path for our code is if we go back to our console and this is the console that we used before.
so it will kind of keep it here in the history.
I can click on that and if I will do RLS here.
Basically this is the name of the folder that we imported with git, so called Django react API is the
name of the folder that we need to put it there.
So we'll go back to web and we go here.
And we need to put that here.
So I will paste it and click okay.
And you can see him home.
My username and then folder is here.
Another thing what we need to do is we need to edit the Wsgi file.
So basically what we have here is we have here if we go to our API we have this is the name of our project.
And we have that Wsgi file here.
So you can click on this one.
And this is the what comes with a Django.
But what we need to do is not to have this as G.
We need to create our own or use their own Wsgi.
So this is actually explained here.
What I will do first is I will copy whatever is here.
I'll copy that.
And here what we can do is you see you have a Wsgi configuration file that is here.
So I can click actually on this one.
And this will open the editor for me.
So you can see here this is the kind of hello world like a default Wsgi.
But I can control or command A.
And I will click delete and it will remove everything.
We don't need their own hello world.
We can paste it.
Whatever.
I copy that from here.
So I copied that from here and I paste it here.
So there's a few things that we need to change.
Like this is command.
So we don't need that.
And we also have this one.
So home.
And then you need to put your username.
So your username will be different than mine.
But I will have like this.
And then we have my site, and my site is basically whatever it's worth.
This because that's the name of the folder that I put it there in the console.
So my site will be this.
This is what I copied that from git.
So it created that folder and it will be here.
So this is the path to my application.
And then you will need to also change this which is basically a place where I have my settings.
So if we go here into API you see my settings are in this.
So this is the name of the application movie writer.
So I will go here and I will do movie Writer like this.
And I have a setting.
So I have a path here that I need to change with a username and the name of the folder I have my application.
This is the name of my application inside the folder.
And then we need to either do this or do that.
So it depends on the version of the Django we are using bigger than 1.5.
So basically we can remove all of that here.
We don't need it and all the comments actually are not needed here.
So they are here just to help you write it.
So this is my new Wsgi and I can click save.
And I can click here to refresh it.
So basically it will be loaded a new Wsgi file okay this is done.
We can go back to our web.
And then if I will go here you can see here we can have a database setup here.
So it depends on what you would like to do.
We can actually have a migrate here.
So I will show you how to do that.
And we can go here.
And I will go back to console and I will open the console.
I had it there.
And here what we can do is I will go to that folder.
So CD course I can click tap to finish writing for me.
So I will go to that folder and I can do manage py because this is where I have my file and then I can
do migrate.
And if the migration has been applied.
So basically if you apply the migration the new database will be created and it will be MySQL database
the same as we have it actually here.
So if you go to settings here you have databases and we have MySQL database.
And this is database created.
So when you run this migrate command it will create that file for you the same as we've done it here.
And so basically you might deploy your you can deploy your application this way.
Or what you could do is you can go to dashboard and you have an option here to databases.
So you can create a databases.
MySQL is free because if you want to go to Postgres then you will need to pay.
But this one is for free.
The small database is available.
You can create this, initialize it, but you will need to go to your settings and you will need to
specify the database engine and the name from here, but we are okay with the one.
We have it there.
So I will go back to web and we should be almost up and running so we can actually check it if that
works.
So if I go here I will reload this application.
So we click on this and that's been reloaded.
So basically this is my application I will right click.
And I said open in a new tab.
And this is my application here.
What I see here is actually a Django error.
And the reason why we have that is we have need to run our Django in that host.
So this is the host and we know how to do it because we could go here and we have option here allowed
host.
So basically if you want to run Django in different hosts you need to tell this Django is running on
that host.
So what you can do is I could put that here, commit it to git git pull and have that version there.
Or I can have the corner.
I'm not going to do it now, but that will be preferable way to do it.
But basically what I need to do is I need to copy that and I can go here into console and we can do
it directly on the server.
So I can go to console here.
So what we have is we we are inside that folder.
So react API I will go CD movie writer I will go to that folder where our settings are.
So I can do ls.
You see the settings file is here.
So I can do use vim again.
So vim and then settings.
And I can edit that directly here.
So I can navigate down.
What we are trying to do is go and put that in allowed host.
So I'm inside that square brackets here I will press I which is an you see that here there is an insert.
So I can do quote quote.
And inside I can do command V or control V just to paste it.
And that's not what I wanted to paste.
I wanted to paste this one.
So we'll copy that and I will paste it here.
Basically my username pythonanywhere.
Com so this is what we need to tell.
So once I in that insert mode I can do escape.
So you don't see it anymore.
You do colon again.
And then you can do X just to save it here and enter.
So basically this has been saved now.
And if I will go here to actually I need to go back from console to my web, I will reload my application.
And if I will go back here and refresh the page, you'll see this is my application up and running.
So you can see page not found because we don't have that in the URL.
But I could do admin.
And you can see here this is a admin page here working on that URL, but this is not ready yet because
like we don't have uh, this nice styles, which is CSS and JavaScript that for, for that user interface.
So what we could do is you actually can see it here.
So you have an additional configuration here that you can do and you can create some settings of it.
I will suggest to read this tutorial because it has a lot of useful information, like for example setting
up environmental for secret key.
So if you put something in the in the production, you don't use the secret key and store it in a environmental
variables.
And it's actually um described here.
But you can also what we can do is we can do we can do it on your own, but we will do the static file.
So basically what we need to do is we need to tell where to store the static file.
So we'll copy the second bit from here.
And I will go back to the console again.
So I will go consoles and I will change that directly in on the server.
So I will use Veeam as Settings.py again and I will go to the very bottom.
So if we'll go.
It doesn't have to be bottom, but there's a reason why I'm going there because we have static URL here
at the last.
So I will do I basically I will go to insert mode.
I will click enter to have a new line and I will paste it there.
So basically what we are saying here, the static URL will be static and static route will be whatever
the base year of this file is and then static.
So that's what we will do.
I paste it so I'll click escape to go back from insert mode.
And I will do colon and then x.
You can see here the command what I'm doing here.
And I enter.
So basically we've done that.
So if I will go here we already had that.
But what we need to do is we need to collect static.
and so collect static.
We will go here.
We already are in the movie rater.
So we need to go one folder up CD dot dot.
And this is where my manage.py file is.
And I can do dot manage py and then collect static.
So basically what we will do here is we will get the static files for that admin page.
And we will put it in the folder that we have it in the settings.
So this has been collected already.
So you can go here, you can change the static URL and so on.
So what we need to go do is we need to close this, go back to the web and then reload it.
And what static does is created that folder static here.
So this is refreshed if I will go console here and run the console again.
So if I will do ls here we have that static folder.
And if I can do RLS static, you can see here since I have admin and Rest framework and so on.
So basically static files have been used and put it there.
So if I will go to dashboard and we actually need to set up there.
So basically what we need to do is in the web we need to change this static URL.
So I will go here.
And inside my web I will go down.
And this is where we have static files.
So static files here.
What I can do is I can do home might be username.
And then movie.
And basically that's the name of the folder.
So it was like this one.
And I will click okay and then URL will be static.
So this is where we put it.
So I will put I will have actually this is not so I will save this I misspelled this.
So if I will click and it should be home.
Home like this.
And if I will save it and then we go refresh it.
And then you refresh this and it didn't work.
So what we need to do I think is we need to also put a static here.
So at the very end I will do slash static here.
So this URL and this you will have the static there.
I will refresh it once again.
And if I will go here and refresh it.
And now we have it.
So you see all the styles here are done.
And we have our application running here on Pythonanywhere.
So this is already done.
I can log in here.
And this is where we have our applications I will close this.
And you can see here I have a list of movies and everything.
So this is working and just fine.
This is already deployed on production.
In the next video I will show you how to deploy our web application using Firebase.
But I mentioned that there a Heroku URL.
So if you will need to use this URL instead.
So whatever you will do there, just not put the Heroku one.
As I explained there, everything will be the same, but the actual URL for our API is your username
and then pythonanywhere.com.
So just remember that whenever I will tell you that in the next section.