Deploying a Django Application on Render for free | Configure PostgreSQL and Static Files

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone I'm back with a new video in today's video we are going to see yet another hosting platform that will assist us in hosting jangle applications we are going to be working with render which will help us uh deploy our jungle application where uh it offers a a free hosting service it has also some other uh packages that you can choose from but for today we are going to be seeing how to uh make use of these uh free hosting service all right so this is a particular website that we are going to deploy our application on so the first thing once you get to this uh page just click on uh create an account or register or if you have one uh login to that particular account then create click on dashboard it will take you to this uh dashboard all right so here we have quite a number of services and uh in this case we are going to be making use of web services so in this video we want to focus on deing a jungle application working with static files and also connecting to uh boost gr SQL database all right so let's click on either new web service or new uh in this section then go with web service so um before you proceed just know that uh render uses the GitHub repository it will only deploy uh web applications available on your GitHub repository so ensure that um ensure that uh you have already push your application to your GitHub repository so that you're now able to uh to deploy it on the render platform all right so uh we are going to work with this first option then click next then here you need to connect your GitHub account so click either GitHub or Gib so whichever that you have right so let's click on connect and GitHub all right so we already in so just need to just need to scroll down all right so let me just select that repository that I want to use so I want to to share this particular repository jungle three jungle online 3 days training let me have it here all right let me select that once I do that let me click on Save right so I've been working with this previously so let me just continue with this so let me connect click connect there so let me give it a name uh let me talk of Jango online that's enough for me then so for the for the region I'll leave it as default for the branch that is the master Branch so for the root our application is on the root uh on the root folder so we do not need to specify anything there then uh run time should be Python 3 then for the um build command we confirm that we have the requirements. dxt we actually have it here right then uh we also need to have this so let me show you what we need to do here so we are told to have gun icon your application do wsgi right so back to our application we need to identify uh the folder with the wsgi.py file right so let me check should be this should be online tutorial so what we need to do let's come back here so we have that that then wsgi right so for your case ensure to uh ensure to to have this folder named accordingly once we do that we confirm that you want to use the free hosting this is it then click on create web service all right so let's give it time to to build our application in case of any errors we are going to rectify that right seems our build failed let me see so for some reasons uh the jungle we told that the jungle version that we have included uh no matching distribution found for this particular version so we can select AOW version so uh the best practice is for you to uh to make the changes on your offline uh repository then push to make the updates on this particular uh repository but in my case I'm just going to make my changes online on my GitHub account then I'll Sy the the changes later all right so let me choose a version lower than uh than the current 4.2 rather 4.2.4 so let me have something like 3.0.0 right let me commit the changes commit changes then back here what I need to do I need to click on that deploy lest commit then give it time let's see if it is going to work all right another error we found another error we told that per per requires version lower than this so uh just to make it easier for us I'm going to edit this instead of having uh this particular version Let me just remove it and also this is not part of the dependencies that uh are supposed to be installed so let me use delete that commit changes commit that right so back to our render dashboard I click on that drop down deploy retest commit right let's give it time all right all right all right so we are told that the build was successful and proing is already taking place so let's give it some more time all right something else is missing we need to add gun icon on as one of the dependencies in our uh requirements.txt so back to this file edit then we have uh G uh commit changes also confirm that back to our dashboard all right let's give it time but uh we're going to stop it right so let me just come here click on this drop down then again deoy as commit and give it time so the purpose of uh doing this uh step by step is to show you how to to debug the errors otherwise I would just have uh uh included all the dependences here with the right versions with with just everything in place but uh for uh since you might be having different versions of these uh dependencies just see how to uh debug them one by by one right so let's give it time all right all right so uh so far so good uh we need to do something else we need to add um jangle online. lender.com in the rest of uh around host all right so what we need to do back here we have uh we have this online tutorial then the settings.py file then click on edit what we need to do we need to either enter uh either enter what we have here that is jungle online. online then back here uh manual deploy deploy latest commit and then give it some more time right all right and from what I'm seeing on the on these um uh Rog display we see that um our application has been deployed let me see if there is any error that has been returned your service is right all right right let me see there to there seems to be an exception but let me just access uh our domain name so we were asked to give it a name whereby we give it jungle online so a subdomain was generated automatically for this particular application so here it is just click on that write an internal server error card uh let me see there's an error here all right this error that we are facing could probably be caused by the versions of our jungle dependencies so let's go back to um the requirements.txt file and edit the the versions so in this case uh if if you remember this is one of the packages that uh we didn't install independently it's a a dependency that was either installed by jungle pillow so in this your requirements.txt has this requirement please remove it then uh for Jungle let's also uh just remove the version and leave it as it is all right so once we do that let's commit uh the changes then let's go back and try to redeploy let's give it time all right so far so good see that uh our service is live so let's navigate and check and there we go so uh most of these errors that happen in deployment are being triggered by the versions of the dependencies that we use so it's uh a call for everyone to pay close attention to these versions well it's not the best idea to to leave the versions as they are in this case on the render platform you might be required to remove the versions and redeploy to check if that resolves uh the the version issue right so the next thing we see that uh our website is now AR but uh we have Rost the stying so uh when it comes to uh this gun icon that uh we have used in this uh deployment um we need to use White Noise uh to take care of our static files so it's the only way that we will be able to uh to have the Styles working for our website so let's proceed and add white noise to our requirements.txt file right so let's visit the White Noise White Noise jle let's visit the the documentation so what we need to do we need to ensure that uh we add it into the requirements.txt once we do that we need to save then next thing let's proceed and see we need to add this midra wa no midra that should be online tutorial then in the settings.py right so let's check let's edit the file then under midra let's add that then back to our documentation we also need to to add this right all right so let us just add it just out this PR or rather we have the static file definition down here we can just have it there all right once we do that let's commit the changes commit the changes then we need to redeploy our application right once you do that let's give it some more time to complete all right I told thatth your service is live let's check right all right and there we go have been able to fix the static files issue as you can see we able to view our website all right so the next thing will be to configure our application to use uh post gray SQL currently we are using we are using the default database which is sqlite 3 right so for us to make use of post gray SQL we need to do something so the first thing let us first come here click on new then we have uh we have post gr SQL database let me close that new post SQL right so uh let's give it a unique name a unique name jungle online jungle online training right uh the database database the name of the database so uh we can just rate as as it is to be generated for us the user we can also re it as it is it will be generated for us then let's go for the region as default for this as default the data dog API key as it is then we we want to use the the free the free tire then let's proceed and create the database all right so as the database is being created we also need to uh to adjust the configuration of our our settings.py file those that um defines the database so first of all we also need to we also need to edit we also need to edit to edit this file the requirements.txt what we need to add is that we need to add uh we need to add a dependency that we take care of that that is a psycho PG to Binary all right once we do that we also need DJ database URL right once we have that um commit the changes the next thing that we need to do we need to go back to our settings.py file this is it we need to edit then let's check if our database has been created all right so our database has been created and we have all that right so what we need we need to First capture the external URL once we capture the external URL let's navigate back to our settings.py file then uh just next to our database settings we have uh right so let me paste what I have here so from what we have obtained uh this happens to be this happens to be the user the the database user then this happens to be the password then we also have the link to our DB that is it right so what we need to do uh in this stage we need to we need to define the default database we need to define the default database this is how to do it data databases default sorry default is equals to we need to have DJ database url url pars then what we have we need to add we need to add that all right so um we also need to we also need to import we also need to import import DJ database URL all right once we do that we need to we need to we need to commit the changes right once we commit the changes let's come back here and uh redeploy our application then let's give it time to complete all right so we see that our uh the build has been successful and we are told that our service is live but if you cross a check on the logs we see that there is an error so you check we have home and scope projects do status from home or that there could be an error on that right so uh if you realize render does not give us shell access where we can do migrations so we have to we have to ensure that uh we do migrations offline so that uh uh such tables can exist so what we need to do we need to Crone this we need to Crone this project we need to Crone this project to uh to our Roo machine once we do that then we do the migration offline which will resolve this error remember we fetched uh the external database URL this was on purpose it was so that we can first connect our project uh lockary do the migration then we can switch to the internal database URL right so um let us scr this um repository let crr this repository get CHR have that so whatever project that we have online this is what we have downloaded on our Roo machine so let's have cd then go online right that's what we have so there is our project so we can simply have Python 3 manage.py make my or rather migrate all right all right all right so um let me let me create a virtual environment this is how I activated all right so can install peep install not install r requirement. txt all right all right then I can proceed and do the migration manage.py migrate so it's going to take uh maybe some few seconds so in the meantime um we can be adjusting the URL to uh to instead of using the external URL let's update to the internal URL for the purpose of uh the online of these uh of these website as we we we already established that uh the error that we we current have is that the migrations were not yet done now that we we we did Crown the these project the migration is already happening and it's happening on the online database so let let us adjust this URL the that we we want to adjust this is it let me click on edit once we do that so the fact that we are using the internal the internal database URL you may realize that we don't have a URL here all that we have is the the username the password and uh the name of the database all right so once we do that let's commit all right then let us be as the let me see right all right the migration has been completed so let's redeploy our application all right your service is is live so let's confirm and also note that we had some projects here which have now disappeared since we have changed from uh sq3 to post G SQL all right so let's try to access the admin dashboard so so let me try to use that password 1 2 3 4 so remember we just did migration but we have not yet created a super user so what we need to do let's create a super user from um from uh the the terminal that is on my loom machine remember this project has already been been configured with the post database that we created online so the super user that we are going to create here will be mapped to the postgress database online so this is the same way you are supposed to do uh your operations connect uh your project locker and whatever command that you run here will apply to uh the database online those particularly the commands that pertains any changes to the database so so what we have we have manage. create super user all right so let me use that email Brank password 1 2 3 4 password again same confirm all right all right once we have that we can just click on login and there we go so the user that we created on uh on on the local terminal has been uh created on the online database so we can try and just create a very simple project here test project let me select a file not sure which file to select let me just select that of laptop let me see your website just copy and paste some some few cors here status let me click on level one completed save so if I come reload my datab my my web page so I have this uh project right so that is it so we have successfully deployed our jangle application on the render platform we have configured the static files we have also configured the project to use postgress database and that is the end of this video uh thank you for watching thank you for uh paying attention to this end uh in case you face any challenge or you have any question please add it into the uh comment section uh if you found this video helpful remember to subscribe to our YouTube channel also give this video a thumbs up and share it with your loved ones thank you and goodbye
Info
Channel: Dynamic Technologies
Views: 221
Rating: undefined out of 5
Keywords: Django, RenderPlatform, WebHosting, DatabaseDeployment, DjangoDevelopment, WebDevelopment, PostgreSQL, StaticFiles, ProgrammingTutorial, CodingTips, DjangoDeployment, RenderTutorial, FullStackDevelopment, DeveloperTutorial, WebAppDeployment, PythonProgramming, WebDevelopmentTutorial, OpenSource, SoftwareEngineering, TechTutorial
Id: lmV69oRldGY
Channel Id: undefined
Length: 28min 23sec (1703 seconds)
Published: Sun Nov 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.