Deploy a Django web app to a Render live server with PostgreSQL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone and welcome to my next video tutorial where I'll be teaching you all how you can deploy a Django web app to render with a postgres database now I have made a lot of tutorials on deploying um Django applications to cloud service providers so it has spawned from Railway to python anywhere to elastic being stalk to AWS fargate and I must say that even though I think Railway is the best option for free deployment I think render is possibly going to come in as a strong second so one of the things that I really love about render is it is extremely simple and I really love the UI of the dashboard and everything it's very simple and user friendly all right so uh that being said aside um another thing that I want to mention of course as I say in the title there is a free plan available in terms of the web server and also in terms of the postgres database of course there will be a limitation to this free service in terms of compute power and usage but anyway I think I said enough on render so let's actually get started so one thing that I want to mention first of all is make sure that you have a GitHub account now as I in all of my videos tutorials I do add all of the relevant links in the description below so if you're unsure of how to get to GitHub I'll just attach a link in description below and you can go ahead and sign up for a GitHub account so you can go ahead and create your GitHub account so as you can see here I am logged into my GitHub account at this moment so make sure you've gone ahead and created your GitHub account and that you're signed into it it's very important that you're also signed into it and I'll explain why that is in just a moment so once you have that GitHub account and you're signed in you can head over back to render.com and you can go ahead and click on get started okay all right so we're going to register for our render account or sign up as they say and there are four different ways in which we can sign up we can sign up with GitHub with gitalab Google and manually here with the email and password now what I want you to do is go ahead and choose the GitHub option here and the the good thing is when we click on GitHub here you're going to see that it's going to ask for authorization to your GitHub account this is why it's important that you have your you that you are logged into your GitHub account you're automatically recognize your username and basically orender wants to do it wants to verify your identity on GitHub and know which resources they can access so basically all we want render to do is access our repository which we will create soon enough so we can give it access an authorize render okay so it's going to redirect and what's going to happen now is it's going to go ahead and ask us to confirm our email so we can go ahead and say complete sign up okay and it's going to say here we've sent you an email at so and so so add your email so you can head over to your email and you can click on render so the first email here is just GitHub saying that it has approved a third party so this is render and here is just asking us to activate our render account so we can go ahead and just activate it by clicking on the following link okay all right perfect so we can now see on the right notification that says email confirmed and we're ready to go perfect so if you got to this stage this means that you successfully created your render account so uh something I want to mention of course is the pricing so you'll see a notification up here that says that pricing has changed please read more on our pricing page so what I'm going to do is click here on pricing page and here you can just read a little bit more detail in depth for how much every single cost here so I wouldn't say it's too much I mean it's fairly cheap okay so of course the individual tier here is what we're going to make use of which is free so we're going to make use of the individual tier um of course you can upgrade if you wish to team organization Enterprise which is custom and the choice is yours so what you can do now is just head over to your dashboard okay so here you are and you can see all of the services that we can make use of ranging from static science web services postgres redis Etc it really is quite vast so what I want to do is just close this notification here let's close that and close this dashboard here and I just want to refresh the page okay there we go so that's fine and I just want to close any this render dashboard okay and here we go so make sure you set up your render account so it's very simple and very easy to go ahead and create right so the first thing that we want to do is we want to go ahead and create our postgres database here so what you can do is you can go ahead and just say new postgres SQL or what you can do is just click here on the right which is much easier you can say new and you can scroll down here and choose postgres all right and we can just go ahead and do that now this is very simple all you need to do is just give a name for your database I'm going to call mine production database okay you can name it anything that you want okay you can set a region here I prefer us East okay Ohio Us East and that's it that's all you need to do so set your region assign a name to your database and you can choose a pricing here um I'm just going to keep it on the free tier here of course that's fine and all we can do is go ahead and create our database just keep in mind here that all three database will expire in 90 days and it will be deleted if we do not upgrade it to another instance type so just keep that in mind in case you're wondering why your database is just missing so go ahead and create your database okay now this is going to take a while okay as you can see the status is creating so this will probably take maybe 10 15 minutes maybe 10 minutes is about a good uh waiting time I would say and we can see everything is just being generated for us as you scroll down such as a username our database Port external internal database URLs a little bit on access controls ipv4 IPv6 addresses was our cider block notations so you can read it a little bit there so what I prefer to do is just click back on the dashboard here and if we well you can see it's already uh set up that's very quick usually it takes some time so we can click on our production database now and we can now see that it is available so it's quite quite uh quite quick actually so everything is set up we have our hostname Port database username which was already there before but now we can see we have a password an internal database URL external database URL and a p uh SQL command so of course we're going to include the settings in our Django application and just to give you guys a little bit of uh context here so our internal database URL so basically this is the URL we're going to use internally within the render Cloud infrastructure and our external database URL is of is something that we can make use of in our external applications such as our Django application so it's just a way to connect to our database from different environments you could say so internally we're going to access it through render and externally through our application but don't think about this too much okay because it doesn't really matter so much about these URLs at the end we're going to connect to the same database okay so just a little bit of context there for you guys all right so make sure if you head over to dashboard make sure that your database is in the available state right so let's move on so just for clarity here I have a simple Django application so it only has a template that basically has one page that says hello from Mario so it's very simple so if I were to give you a bit of a preview of my application so all I've done is I've created a simple app created a template called index.html that says hello from Mars in a H1 tag that's literally it there's nothing else nothing nefarious or strange here um of course I have my allowed host secret key debug I haven't modified that yet we will get to that momentarily but basically everything is very simple straightforward is nothing real to tricky or anything like that all right so to make use of a postgres database in Django we need to go ahead and install a package now the package that we should install is called syncope pg2 binary okay so this is basically a python postgres database adapter so it's going to help us if we want to make use of a postgres database was in Django applications now usually you can make use of just a psycho pg2 but the psycho pg2 has issues usually when you're deploying it's better to use the binary version that's just uh from my experience so what you can do of course is head over to your application so here is where my project is currently located so just to give you Clarity so I've created just a simple folder on the desktop with my Django project was in that and of course you can see the location that I've seated in I also have a virtual environment here just outside my project that's where I prefer to keep it as you can see I'm currently within it so if I were to type in the command pip list so just type that in as you can see here I only have a Django okay all the other packages here are just part of um pip and all the sub packages that come along with installing Django because when you install Django you also installed other packages so don't worry about the rest it's all part of Django so all you'll have here is probably the same as me all I've done is I've gone ahead and just set up um a simple application and only installed the Django package within my virtual environment along with Pip which is the default but more on that later when we create our requirements.txt file then you can see exactly what I use and I will explain in detail so you don't need to worry anyway so let's get back to Psycho pg2 binary and we can just type CLS and what I want to do is go ahead and install that package so I'm just going to copy it go ahead and install it like so and there we go so it's been installed so we can now say pip list let's verify that so psycho pg2 it's installed great perfect so that's the first package that we need to actually make use of postgres database in our Django application um something I want to mention before I go on I do take my time when I explain Concepts so I do apologize for those of you that want to really get going but just to um be clear so you actually understand what's going on I think it's best for me to explain in detail rather than rushing over it because you're just going to try and learn the same thing twice where you can just do it once if you have a better understanding but to be honest you can skip ahead if it's a little bit annoying I completely understand so it's no problem all right so the next thing we need to do is we need to go ahead and install this package called DJ database URL so let me explain why we need this package so to remotely connect to our render Pro postgres database we need to configure our external database URL so if you click on your database you'll see here we have an external database URL and this is what we need to configure in our Django application okay and this is and this package here DJ database URL is going to help us to make this configuration to connect our external database to connect to our postgres database using the external database URL to our Django application okay and basically this package is going to transform this database URL which we have right here I won't uh won't show well I can show it doesn't really matter so this database URL here it's going to transform this database URL into Django's database parameters such as user um and database the DB name so name Port host name it has all of that in place so to give you a bit of a better idea of the markup of these database URLs I will attach a useful Link in the description below which actually shows you the markup for this URL in terms of the user the name all of that all of the parameters that you'll usually see for your database configuration so just keep that in mind okay so we can go ahead and install that package so let's go ahead and install that so DJ database URL there we go perfect okay and let's do the next one so the next one that we need to do of course is we need to make use of a package that helps us to make use of environment variables in Django now there are many packages that you can use I prefer Django and viron or python decouple of course you can make use of your own ones as you wish you can use dot EnV it's really up to you I just prefer Django environment but it's very simple and easy to make use of it's not difficult or anything so as if you guys aren't aware of what's the point of this package so it's it's used to help us to create environment variables and environment variables are used to keep all of our sensitive information private and a typical example that will lie in our external database URL so typically you would also add other things to keep that private but this is just uh one use case all right so we can go ahead and copy that go ahead and install it right Django environment I need to check it so I like to be sorrow here so let's see what we have so DJ database URL installed Django Environ installed Soco pg2 binary Django Environ all set great so we've installed most of the packages there are more but we'll get to that soon enough so what we can do is just close these up um for now that's fine Okay so we've got everything set and installed so that's that so make sure you've installed the following packages so DJ database URL Django Environ and FICO pg2 binary okay so make sure you've got that all in place so we can head over to our application so head over to your own Django applications because what we're going to do next is we're just going to configure everything accordingly all right so next we can start to Define our render postgres database settings as follows so we're going to head over to our settings.pi file so head over to your settings.pi file all right and what you can do is just find a good place to enter in your PostScript your render postgres SQL database uh credentials and information so here is what we're currently using the SQL Lite database here so what I'm going to do is just comment that out okay let's comment this out so this is what we're using over this moment so I'm just going to copy out comment out the sqlite database so here we have the render postgres database and we are going to make use of that DJ database URL because we need to bring in this external database URL okay so that was the whole point of that package from earlier so what you can do here is say import DJ underscore database URL okay and then what we need to do is just add some mockups I'm going to say data bases equals and open my curly braces and it's literally just going to be one line and all we're going to do is say default and I'm going to add my colon and here I'm going to say DJ underscore database URL dot parse and in quotes here we're just going to add quotes what we need to do is we need to pass in this external database URL so we can go ahead and copy that and we can add that in like so but okay this is where our environment variables come in this isn't a very secure way of doing it okay it's not the best way of doing it either so this is the whole point of making use of our environment variables because this can be seen as sensitive information which in fact it is because you don't want anyone to externally connect to your database even if even if they don't know your database uh peripherals and information this is very insecure so there's no need to do this we can just take this out okay but that's just one way you can do it if you wish and remove the quotes so what we need to do is we need to set up our environment variables so that is what we need to do so you can go all the way up and scroll to the top so something I want to mention before we import uh Django Environ is sometimes you'll get a warning at the bottom of certain packages you may have already gotten a warning here under a DJ underscore database URL and the reason for that is sometimes you need to make sure that your python interpreter is set up correctly so what I mean by that is you have your virtual environment folder here so if I go out if I open my project here I have a virtual environment folder so sometimes you need to set up that interpreter so what you need to do is just say Ctrl shift and P on your keyboard so again Ctrl shift and P at the same time and it's going to open up this menu here so what you can do is you can say python select interpreter and what I like to do is go ahead and say enter interpreter paths okay and then what I do is I head over to my virtual environment folder of my project copy that location and head over to visual studio code enter in that path and go ahead and just press enter okay so if I press Ctrl shift and P and select interpreter we can see we have one selected so of course that's also set to my python version as well okay so just keep that in uh keep that in mind all right right so let's carry on where we were so we want to set up our environment variables so we already have installed the Django environment package but we actually need to import it so right here at the top of your settings.pi file this one actually creates that folder what we can do here is we can just say import Environ okay next thing that we need to do is we need to initialize our environment variables with Environ so to do that we can just say e and V is equal to Environ dot EnV in parentheses and we can say Environ dot env.read underscore EnV so we're just configuring and setting up our environment variables to be configured all right next thing that we need to do is we need to create our EnV file so what I suggest is when you create your dot EnV file is you must create it within the directory where your settings.pi file exists so I'm just going to say right click here on Elevate new file call it dot EnV and also another helpful tip here when you are adding environment variables Etc to your dot EnV file make sure when you upload it to GitHub that you make use of git ignore and you get ignore your dot EnV file when you're uploading code to your repository so just keep that in mind okay perfect so that's sound ready to go so we have our EnV file set now the next thing that we want to do is we want to go ahead and we want to set up our uh our environment variables so you can use it for whatever you wish okay so a good start would be your secret key it can also be your database URL as well so there are several things that you can go ahead and make use of so the one thing that you need to bear in mind with this Django Environ package is you cannot use quotes when you're assigning your environment variable so for example if I was making use of the secret key here I would have to copy everything within the quotes and the same thing as well was the external database URL they cannot be quotes for strength so I'm going to go ahead and Define it as database underscore UL and I'm going to say equals and what I'm going to do is head over to render and I'm going to copy the external database URL so make sure you copy the external database URL not the internal because external we're using it outside of Django so you can go ahead and copy to the clipboard and paste it in like so make sure you don't have any quotes leave it just as is right next to it now we have database URL and we want to reference this in our settings.pi file so head over to your database here where you're instantiating your render progress database and here in pause all you want to do is you want to use the environment variable markup which is EnV and in parentheses we can go ahead and add in that secret key which we so-called named database URL and we can add that like so okay so that's all you need to do to get this up and running so you just need to say EnV and then within parentheses you can just put in the quotes all right so let me show you how this is done so what we can do now is we can just say python manage.pi run server okay and you'll automatically see that it says you have 18 unapplied migrations so this implies that we in fact are connected to our postgres database in Django because it's saying we have unapplied migrations now let me show you if I take this out clear that out and let me remove this whole line just to show you what I mean and rerun your server again we can see we have an area here already because we're excluding this but let me show you for example what's the better way let me comment this out for now and let's rerun the server okay you can see now that it's not showing any unapplied migrations nothing at all so this implies that we are correct so let's go ahead and add and uncomment this now so that means that we are connected to our database EnV and here now another thing I want to show you before we do this is just to help you graphite idea of environment variables so for example if I were to change this to something else and I say the underscore database URL and I'm just referring here to database uh what's it data the database URL and I put it in incorrectly let's say I run my server we can just double check here that this is in configured and we can see here that it's actually reading from our DOT EnV file so this tells us that Django environment is working as it should okay so let me take that out okay so now we're going to do it properly now so here I have database underscore URL and here in my environment variable I'm calling this value here for postgres and it's going to be data based underscore URL now let's go ahead and run this now properly okay okay so the unapplied migration perfect now we can actually go ahead and actually migrate everything as it should be so we can migrate so let's do that so I'm going to say Python manage.pi and I'm going to say migrate okay so it's going to make all those migrations for us as we so now we are connecting to our postgres database in render so that's effectively what we're doing now so let's just wait for everything to connect so what I'm going to do is pause the video because this will take a while and I'll get back to you when this is done so let's just wait for that right perfect so we can see the migrations were made and what we can do next is create a super user so I'm going to say python manage.pi create super user okay and what I want you guys to do is create a memorable super user okay so something very memorable and the reason for this I just want to prove to you guys is the fact that we have an internal and external database URL and I want to prove to you guys that if we have our external database URL set in Django and our internal database set in render which I'll show you later on just to prove that it's connected to the same database so that is the reason why I'm asking you to create a memorable Django admin here so I'm going to call this admin admin 100 so that's quite memorable for me so choose something that will stand out that you'll remember so you don't forget okay uh email I'm just going to leave that blank password to your innate password perfect and sapu is created perfect so let's just run our server let's just make sure we don't have any issues or any problems uh great okay that's fine uh let me go to my application okay that's fine perfect all right so that is good to go so we've got that up and running as it should be so our super user was created now what we can actually do is we can actually go ahead and we can open our connect to the admin page so we can go ahead and just put an admin and go ahead and enter in those credentials here perfect and go ahead and log in okay so the fact that it's taking some time is good because it's remotely collect connected to a cloud service and there we go we can see that is all set perfect so we have connected to our postgres database um as it should be connected all right great so we've got that out of the way so the last things that we need to set up is just the final settings here so feel free to also set your environment variable up for your secret key just remember like I said you cannot use quotes um here in your database or L For Strings you cannot you need to remove those quotes just add in the Raw value okay uh next debug should be false a loud host for now we can leave it a star I will give you guidance uh later on so we can just leave that as is so make sure the most important thing is debugged to be set to false and yeah that is pretty much what we need to do there all right so in order for our Django web application okay to connect to render properly and for us to actually deploy the application we need to make use of a package or or a service called G unicorn so G unicorn is a HTTP server for Unix and it's going to help us to bridge the connection of communication you could say between our Django application and the render web servers so this is what we need we need G unicorn and you could say in business terms unicorn is sort of like the intermediary like the middleman between um of course uh Django and uh render so we need to make use of this package so what you can do stop your server and in your virtual environment make sure you install the following package so go ahead and do just that there we go and we can type list let's verify it so do you know corn there we have it perfect all right so that is good to go now the next thing we need to do we can close this up this is fine we need to make sure that we install or we generate a requirements.txt file so what you can do is you can go ahead and say pip freeze make sure you own your virtual environment so you install the packages in your virtual environment and not globally greater than requirements Dot txt okay there we go you can see it have it just was created open this up and these are all of my requirements is literally barely anything so make sure I'll zoom in for you so make sure you use these for your first deployment as I always say when I make video tutorials make sure you start off your deployments very simple don't try and add a complicated project for your first time because this will demotivate you to actually deploy your Django application the second time so make sure at least the first time that you deploy the success and then you'll give you motivation to go ahead and experiment with other packages so this is what you should have at least in your application in terms of the Django version ASA getif SQL parts and TV data that's going to depend on your Django version but try to have a a new Django version I would prefer maybe four and up I would say but make sure you also have psycho pg2 binary for your uh postgres database G unicorn to bridge the connection between your Django application and render uh Django environment for your environment variables a DJ database URL to help you to connect to your external uh to your postgres database using the external database URL okay so make sure you've got these in place what I'll do is I'll also add this I think I'll pin it as a comment on the video I think instead of the description that will be a bit more clearer for you guys and more accessible so just keep that in mind you need these all right perfect so there are the requirements uh that we need all right so make sure you've got that in place and that you've configured all of the other uh settings accordingly right so let's prepare everything and get everything organized so what we can do is just close the following and of course our localhost and what we can do if we as we are in our production database settings we can just click on dashboard and we'll see it right here we can do now is right click on render dashboard duplicate it so we're going to refer back to the database that's the reason for opening another tab you can head over to the dashboard go ahead and say new and you can choose web server so this is for hosting our live server okay and here we are on this page now what you want to do first of all is head over to your GitHub account and you want to create a repository so go ahead and create your Repository now the repository name that I'm going to call now of course for those of you that know how to deploy to GitHub there you'll know there are a million to one ways to do it I'm just going to show you one way that's very simple of course you can go ahead and make use of your own way VIA commands Etc I'm just going to do a very simple way so the repository name that I don't like to name it as would be the name of my folder because what I usually do is create the repository with the name of my folder and I'll click in my folder and into my Django project Elevate and copy everything within that so that's what I usually do so I'm going to name this Dev uh description I'm going to leave open I'm going to keep it as public I'm going to add a readme file and I'm going to create this Repository okay so go ahead and create your own Repository all right there we have it say I'm ready to go and what we can do now is just drag our files here it's very easy to do this and I'm going to head into my project Dev Elevate is my Django project and I'm just going to go ahead and copy everything make sure that you have your requirements.txt file in place as well so once you have that head over to GitHub and you can now just drag in all your files here that are necessary go ahead and drag that in here okay all right so it's just being uploaded so this should be relatively quick so some important things just to make sure so make sure that you sent allowed hosts of course earlier on here make sure you had the following settings here allowed host to all or else your deployment will fail so make sure you have this set but I did mention that earlier so make sure just double check you can always edit your files here it's not a problem so once you've got that once it's uploaded you can scroll down and just commit those changes so I'm just going to say here first commit and commit my changes okay so it's just going to go ahead and process those files let's wait for that so it shouldn't take too long and then what we can do is go on with the next set of steps so there we go our repository is all set I'm logged in my repository is called Dev and here is my code great so what we can do now is connect our repository but to do that we need to add explicit permissions to allow render to view our repositories so I'm just going to drag GitHub here right next to it and I'm going to say connect account okay and now basically all render wants to do is access all of our repositories or select repositories so you can choose which one I'm just going to keep it as default and say all scroll down and install it okay all right there we go so render has been connected and we can see now that it's connected to our repository here so if we had all repositories it would show all of the repositories and we can now see we connected to my GitHub account here as well and it's all set now all you need to do is you need to go ahead and connect to that repository that you're connected to here and say connect okay perfect so we only need to add in a few details here and not much here so first of all you want to enter in your application name I'm going to call it Django app and we can choose your region I'm leaving it as default the branch leave as default route you can leave a default environment you can leave build command you can leave it as it's going to install all the requirements in our txt file that we defined right here so we're just going to install all of these and configure it in the in the build and here we need to set the start command so this is where we Bridge the connection like I said earlier on between our Django application and render itself so I'm going to show you a good way of figuring this out so what you can do is head over to your settings.pine visual studio for example scroll down until you see something that says wsgi application now as we know G unicorn is going to help us with this wsgi sort of bridging so take a look at what the project name is here so our project is called Elevate here and it's defined here as well so Elevate dot wsgi dot application so we need to make use of this in our G unicorn here but we need to add a colon here instead where it says wsgi to application we need to add a colon so this is where we're referencing it from so you're going to need to want to reference your project so what we can do is just remove app and we can keep the g-unicorn there and I'm just going to say elevate Dot wsgi and instead of adding a DOT I'm going to add an app a colon and reference it to application like I said okay so go ahead and add in the following for your own application with G unicorn and this is going to help to start the process all right so make sure you've got everything in place you just really needed to add the name and configure your unique stock command for G unicorn uh we're going to use the free instance type and now we need to click on Advanced okay so now it gets important and we need to add our environment to variables so something that I want to mention by default render automatically makes use of python 3.7 which is probably for most of us is very old so you need to explicitly hear State your python version which is very strange I mean you'd think it would be in another section but for some reason it's in the environments variable section here but that's just how it is very strange so go ahead and enter in your python version okay now something to note here okay um try not to use an older version less than 3.7 and try not to use one of the newer versions I'm talking about python 3.11 um and a very new version like the latest because usually there's bugs and issues with that so I would rather wait until later versions come out so a safe version so remember we are using Django 4 in my Django four point let's see we're using Django 4.1.6 and Django 4.1 is generally going to work nicely with anything from the late 3.8 the whole 3.9 series and most of the 3.10 series was python so it was a very safe bet to go would be 3.10.6 so python 3.10.6 would be a very safe version that's the one that I'm making use of so I'd recommend this uh version okay so sometimes you'll get an error where it says deploying forever if you use the wrong python version so do keep this in mind this is uh one of the factors in terms of deployment failures so make sure you choose an appropriate python version for your Django version as well okay one that is you kind of have to Wing this a bit but 3.10.6 is something that I've tested that works nicely for the latest version of Django so this is something that's a trial and error thing that you have to test and work on your own okay uh once you're happy with that you can add another environment variable and this will be our database URL so remember we can we configure a database URL uh right here in our Django application but in this case if we head back to our production database in the other tab we now need to refer to that internal database URL now so external we reference that in our Django application but now we need to reference the internal database URL so you can go ahead and copy that the internal database URL and you can put in here the value for that database URL you can just set that right here so that's all you need to add you can add additional environment variables maybe you want to add in your secret key debug equals to false Etc and maybe you have access keys from AWS I'm not too sure you can just add those environment variables here just remember with Django and viron you can't have quotes in your values okay so once you're happy with that scroll down and go ahead and create the web service and that's pretty much it so let's create it 'll just take a moment to create that service okay and there we go so it's just cloning and it's cloning from GitHub as you can see checking out that latest commit that we went ahead and pushed so this commit here first commit um is just checking that out and we can see here it's going to use this python version 3.10.6 which is relatively new it's going to install all of the packages and it's just going to now build our application Itself by generating a container image from our Django application now do keep in mind that the build does take a few minutes um maybe about five to seven minutes I don't know it really depends can take longer so it does take some time to set this up sometimes it's very fast it really depends so what I'm going to do is just pause the video until the build is complete and the deployment is complete and then we will go from there and go into further detail so let's just wait for this build to be completed first of all all right so we're back and now you can see the page may have refreshed for you it did refresh for me and what you can do you'll probably be refreshed to this page right up here at top and it will say live so you can see applications now live now if you scroll down you'll see all the dependencies were set up and our application was built the build was completed success with the nice Emoji there and our application was deployed using the following G unicorn um configuration that we set and we can see everything's working as it should now the final verification is to right click and open this this is effectively our URL so we have a custom URL here and we can right click and open that link in a new tab and there we go our application is now hosted on render it's all set and ready to go all right so that's pretty much uh that guys so that is how you can go ahead and deploy your application uh to render making use of a postgres database and also going ahead and deploying your live server to render so that's that guys right so before we finish up I just have one more thing I want to mention and that is some of you are probably wondering about static and media file through image files so I would recommend making use of something known as Amazon S3 buckets now in my opinion this is the easiest and also the cheapest way to set up your static file structure I do have a video on this so I'll be sure to add that in the description below and one more thing that you guys will probably have in your mind is the admin page so you may notice that when you head over to the admin page that you will see that it's lost its styling a bit so what I'll do is I'll add another Link in the description below addressing this particular issue and it will give you a solution to solve this so it's a very quick fix so I'd recommend that you go ahead and look into that if you are wondering about the standing for the admin page I will attach a link and make it very explicitly clear in the description below about that all right so that should address most of your queries so we at least have our postgres database up and running and we also have our Django application Live our live server we have that also running um and of course static and media files of course you can check my Amazon S3 buckets video on how to set that up and also I'll also add a link to the solution to fixing the Django admin styling down below as well that should fix that um the last thing I can think of is you're probably wondering about the domain name so this looks quite boring and meticulous so what you can do is you can add a custom domain name as well that's also something that you can actually add to your application just to you know use something different that looks a bit cleaner than this instead you can go ahead and add that domain name right so if you want to add this domain name or you can do scroll down here on the left head over to settings and you can scroll down you can see all the pre-filled settings that you did before scroll down and here you'll have custom domains so we can see our server will always be available at the following domain name here and we can also point this to a custom domain and what you can do here is you can go ahead and click on ADD domain look for a domain name save it and I'm sure it'll take you through a process of going ahead and setting up the domain just remember once you've set up your domain remember in your allowed hosts setting in settings.pi of your Django application to add in that custom domain under allowed hosts or else you won't be able to actually access that domain uh one final other thing that you will probably need if you're using a custom domain with https be sure to set your csrf trusted origin Property as well very important so I would also recommend looking into the csrf trusted origin so that's something that you're also probably going to have to set in your Django settings.pi file with your domain so remember those two things for later on if you want to use a custom domain okay guys so I think that's pretty much it I this is a very long video but I want it to be thorough and give you as much detail as I could so yeah that's about it guys and yeah I'll attach everything that I said I will um and yeah everything that I mentioned so just check that out and yeah that's it guys and as always thank you for the support I really appreciate it and until next time see ya foreign [Music]
Info
Channel: Cloud With Django
Views: 23,728
Rating: undefined out of 5
Keywords: Cloud With Django, CloudWithDjango, cwd, CWD, cloudwithdjango, Deploy a Django web app to Render with PostgreSQL, Deploy a Django web app for Free, Free deployment, Deploy Django free, Django free, Django, Django web development, Django web developer, Python deployment, Deploy Python app, Python programmer, Learn Django, Host Django app, Free deployment Django, Django free live server, Deploy postgres, Deploy postgres database for free, Render, Deployment, Deploy Django, Deploy app
Id: AgTr5mw4zdI
Channel Id: undefined
Length: 46min 57sec (2817 seconds)
Published: Wed Feb 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.