Deploy a Django web app to Python Anywhere [FREE]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone and I hope you're all doing great so  welcome to my next video tutorial where I'll be   teaching you how to deploy your Django web app  to python anywhere now I know some of you are   probably wondering so let's go over and click on  pricing and sign up so if you see it here it does   come with a free version here but just do bear  in mind it is extremely limited but of course you   will be able to at least deploy your application  here and it will be live alright so just bear in   mind that there are other pricing plans available  some of them are a little bit expensive but just   rest assured that there is a plan that is free  and what you can go ahead and do is you can go   ahead and create your beginner account all right  so go ahead and create your beginner account and   then we'll move on to the next stage all right  so make sure you go ahead and do just that so   once you've created your beginner account you will  then be able to actually log in with your account   um actually what will happen is once you create  the beginner account you'll automatically be   logged in once you complete the sign up process  okay so make sure you do that create your account   um remember to get there you just need to  go to pricing and sign up here in the top   right so yeah that's maximized and according to  this URL here so it's at www.payerson anyway.com   and what I can also do is I'll attach the link  also in the description below so you can just   click on that if that will be easier for you so  go ahead click on pricing and sign up and just   start by creating your beginner account first  of all all right all right so by now you should   have created an account on python anywhere and  you should be able to access this location here   that is your dashboard so usually you'll be  redirected to this location if not for some   reason just have a look here at the navigation bar  and look for dashboard click on it and it should   be redirected to this location here all right so  as we can see my username is honor96 so you will   have your own username displayed here with a nice  welcome message and you should see this page here   something else that I want you to make sure make  sure that you have a GitHub account and you are   currently in the repository of the application  that you actually want to deploy so what you can   see here is let me go to my actual um account  so I am using my crowd with Django account and   you can just head over to your repositories okay  and I'm going to make use of my basic app here   okay so this is the application that I'm going  to make use of and you can see here that would   be my URL so make sure you go into your project  on GitHub accordingly all right so once you've   done that what you want to do is scroll down and  here on the bottom left you'll see something that   says new console what you want to do is you  want to head over there and click on bash okay   and this will open a nice console for us okay  so it's just executing great now I know this   is a bit small so I will zoom in a bit okay  that should be okay it's that let's see what   that's I'll zoom in a bit more okay there we go  okay that is that should be good for you guys   all right so let's get started so the first  thing that we want to do is we want to head over   okay and go to our home directory here so to  do that okay we can say PWD okay and now we're   in our home directory so it shows home and  then honor 96 so that will be your username   so make sure you are here next thing that we  want to do is clone our project so I'm going   to say get to clone and then go to GitHub with  where my project exists copy that URL and paste   it in like so very simple press enter okay and  it's just going to clone our project accordingly   now I don't like to have all of these lines here  it looks very unclean now a useful command that   you can use here in the bash console is to  say clear and that will clear everything up   so look a bit cleaner a lot better and so on  so just be sure that you go ahead and do that   so in Python anywhere um we need to actually  create a virtual environment so this is just   how python anywhere works so to do that we can  say MK that means make virtual EnV so basically   we're saying here make virtual EnV which  means make virtual environment then space two   dashes and then we're going to include our python  version so first of all we're going to say python   is equal to a forward slash user so a user in my  case honor 96 and we want to go into the bin okay   and now we're going to put in the python version  so I'm running python 3.9 now a way to check   what version you're utilizing head over to your  command prompt okay and you can just say python   dash dash version okay and it's in my case python  3.9.13 you don't need to use the last extension   just say the first two uh first two digits is  fine so 3.9 3.8 3.7 that's fine now I do want   to warn you here that you might have a problem  here because I don't think python anyway supports   python 3.10 so you might have an issue with that  so as long as you're using python 3.9 and below   you won't have any sort of problems or anything  so I'm literally at the edge here because I'm   on python 3.9.13 so just bear that in mind okay  so apologies for that next thing that you want   to do is you just want to add a space and now  you're going to name your virtual environment   so I'm going to call mine venv now make sure you  remember what you call your virtual environment   because we're going to reference it later so  if you want to if you want to write it down or   anything I mean it's only going to be like a few  letters but just I want to place emphasis that you   need to make sure that you remember your virtual  environment okay and now you can press enter   okay so it's going to now create  our virtual environment for us   delicious wait for that okay there we go  uh perfect and now we can see we're in our   virtual environment accordingly now I just  want to clear this mess up there we go okay   so let me explain this clearly here so if you  happen to have a requirements.txt file okay   we are currently in our home directory as of this  moment so what you can do if you want to go ahead   and say pip install our requirements.txt okay  you can head over to your project directory you   can just CD over there and then run that  pip install our requirements.txt so in my   case my project is very simple here I mean  I haven't got anything crazy here going on   um if I open my project here Elevate here we can  see it's it's very simple there isn't uh much   going on all I really need to utilize is a Django  so I'm just literally going to go ahead and say   pip install Django now remember what I said what  you're going to need to do if you want to install   your requirements.txt font you're just going to  have to CD to your your Project's directory and   then go ahead and install your requirements okay  so in this case I'm just going to install a Django okay so let's go ahead and do that  okay so this should be relatively quick   okay so what we can do what I'm going to do  actually is wait for that to install so I'm going   to go ahead and pause the video and once that's  done we can move on to the next step all right   all right perfect so we can see our Django  Apple installed perfect so let's clear this   up all right so we're going to have to open  multiple tabs now so what we can do here   is we can just duplicate this tab okay and  what we can do is actually just go back here   and here we add the dashboard so we can zoom  out here this is a bit crazy okay so what I'd   recommend is you open a few tabs here so duplicate  a few here because we're going to be using   a lot of things okay so it won't be difficult or  confusing but we don't want to have to open tab so   just go ahead and open a few tabs on the dashboard  because we always want to refer back here   so you'll be glad to know that we're now finally  done with our bash console so you don't need to   worry about this anymore for now at least for now  okay we will return to it but we're done for now   okay now the next thing that we want to do okay  uh head over to your dashboard and you can see   here it says open web tab because we have no web  apps so let's go ahead and say open the web tab   okay okay so it says you have no web apps  great okay let's go ahead and create a new   one so add a new web app okay so we can see  here your web app's domain name so for me   it's going to be honor 96 so it's going to be  your username.payersonanywhere.com now you can   go ahead and add a domain name so you go ahead  and say upgrade now and go ahead and change that   accordingly if you want um but remember it's  going to cost you money so if you just want   to keep it as is and you just want a uh your  application Live okay free without any sort of   um Hang-Ups or anything just  go ahead and just say next okay   okay next okay we need to select the python web  framework and I know most of you are going to   say Django now we're not going to do it that  way we're going to do it manually so you'll   click on manual configuration and now you need  to choose the python version now this is why I   said earlier on in the beginning make sure that  you have lower than python 3.10 because python   anywhere as of this moment does not support  it so in my case I'm literally right at the   end so I'm going to choose python 3.9 okay uh  great so we're going to manually configure our   wsgi configuration file this is actually very  simple so not to worry now we can say next okay so let's just wait for that so  it does take a moment to configure   and there we go so our web app is set up  correctly as it should be okay so there we have it   all right this is great now what I think we should  do we can close these links here and we want to   just make a duplicate of this one here okay great  because what we want to do in the end is the   reason why I'm duplicating it is because I want us  to connect to this URL in a moment not now because   it's not going to work so we can scroll down and  scroll all the way down until you see virtual EnV   okay so what we want to do here okay is we want to  add in our virtual environment now if you remember   early on in our case we call it venv so this  is why I said you must make sure you write it   down or remember it because we just want to add  this in here so venv go ahead and add that in   perfect so there is our virtual environment air  location our path for python anywhere great now   what we can do now is we can go ahead and we can  alter our wsgi configuration file so what you   want to do is click on your wsgi configuration  file it should be just above the virtual EnV   section so under the code section here and just  click on wsgi configuration file here okay just   open that up okay here it is okay so what you  basically want to do is you want to scroll down   here all the way down until you see a Django now  everything here in Django you don't want to delete   so everything from 89 to 74 to 89 just leave it  everything else you can delete so if you want   some clarity you can just watch what I do so I'm  just going to take flask out here okay I'm Gonna   Leave Django Uh custom wsgi you can take that  out uh the virtual Envy this is just a comment   okay this whole application here we can remove all  the way to hello world so from line 13 hello world   uh all the way to line 53 that says live okay you  can go ahead and remove all of that okay and we   can leave this up to here so we can scroll go  back up here and make sure you have Django here   okay so make sure you're up to this point next  thing that you want to do is you want to uncomment   accordingly so watch exactly what I uncomment  very important okay so I'm going to uncomment the   application uh the from Django the OS part here  okay our if statement okay that's fine uh our pass sis and Os okay so everything here we need to  make sure that we uncomment accordingly okay   so everything else is a comment as you can see  here these are just comments and we don't have   if then so that is a comment as well so make  sure you've got the following as I have so   import uh OS import sys um pass if password says  pass uh sysports.append I was done in viron from   django.core wsgi import get wsgi and application  okay so to summarize what's going on here   basically is we need to set the pass to our actual  application so that's effectively what we need to   do next we need to set that pass accordingly all  right so what we can do now is head over to the   bash console so here unfortunately back again  I just want to zoom in for you so make sure you   head over to the bash console so what we want to  do no I'm here so what we want to do now I just   want to go back out of here so what we want to do  now is we want to get the pass of our application   from The Bash console and copy it from bash and  just edit it right here where you see the pass   right here we just want to edit that out okay so  head over to bash and let's get started with the   configuration right now the first thing that we  need to do is we can type LS so Alice is going to   go ahead and show us all the files in our current  directory so here in our home directory we have   basic apps so if you recall basic app is the name  of my repository well my repository here basic app   that's the name of that let's go ahead and CD  into basic app in my case so in our application   okay okay and type LS let's see what we have  Elevate so Elevate is my actual project here   so Elevate if I click on that here this is my  actual project okay so I'm in it right here   as you can see so I'm I went into I seeded  into basic app which I did right here and   now I'm cd-ing uh into basic app which I can  see Elevate um right here at the end of this   moment so if I type LS I should see elevate  linksmanage.pi so if I exceeding to elevate now   okay and type LS okay there we go we can now  see manage.pi uh links and we can see all of   the following accordingly all right so make sure  that you are here as of this moment so now we   are actually in our projects directory Great  so the next thing you want to do is type PWD   okay and this is going to actually give us our  projects directory here so in my case it's in   the home directory under my user honor 96 a  basic app elevator so Elevate is my actual   Project's name so you can check that accordingly  here so I have a fully here called basic app   and then my actual Django project itself here  okay so I don't want you guys to get confused   so here we are and this is the pulse that we need  so we can copy this pass here accordingly so let   me copy that nicely so you can copy that you  can press Ctrl C uh head over to this part here   okay and here where you see the  path we can just replace that   like so and just remove those comments for  a moment okay and we add them okay there we   go so we just want to add a fresh pair of uh  quotes sorry not comments quotes okay there we   go so there is my app pass okay perfect all  right so you want to go ahead and say save   okay so this has been saved so our wsgi font has  been configured appropriately okay and next thing   that we want to do is we want to configure our  domain name here so this is our domain name rno96.   pythonanywhere.com go ahead and copy the domain  name head over to uh we can head over to files   okay so just get over there and what  you can do is you can head over to   your basic app here so this is my  repository name basic app elevate   okay and I'm going to go into my Elevate settings  so I'm going to my settings.pi effectively   and what I want to do here in allowed hosts  okay I just want to put in the following here   so my domain name okay just uh bear in mind  you should actually turn the debug setting   to full so just a bit of a security tip there  so make sure you of course change it to false   but the main thing here is make sure your loud  hosts is set accordingly here after you've edited   that go ahead and say save okay and what you can  do is you can go out of this so you can go back   so make sure you go back  head over to your dashboard okay great now once you've done that you just want  to head over to your configuration files here and   there's one thing you want to say here and that  is your settings here so depending on what you   named your project in Django so in my case here  I called my project Elevate here so this is where   my settings.pi exists so if I click on that okay  this is where my settings.pi is and that is my   project here so you want to set that accordingly  here so I'm going to call mine here elevate like   so make sure you add that as follows make sure  your pass is all set and go ahead and say save   okay so that's saved great now now that you're  on your dashboard here what you can do is you   can go ahead to your web app here so go ahead and  click on your web app here in the bottom right on   all web apps okay and before you actually go  ahead and connect to it you want to reload   um your file here accordingly so go  ahead and reload uh everything here   okay so that just that does take some time  okay there we go and now you can open up   your application at this domain name so open  that up and there we go so I had a very simple   application but now we can see our application  is now hosted um from python anywhere do bear in   mind okay that this is free so you don't need to  worry about payments although it is very limited   in terms of the CPU they give you it's very weak  and very low but you know it is a way to you know   deploy your application and like I said you can  even go ahead and custom your domain name okay   so that's it that is the basic way as to how to  deploy your application get it running get it   set and everything so this is an alternative way  of deploying your Django replication to python   anywhere for free so I hope to help you guys  it's very simple and relatively straightforward   so yeah that's it guys and thank you as always  for the support thanks so much till next time
Info
Channel: Cloud With Django
Views: 88,098
Rating: undefined out of 5
Keywords: Cloud With Django, cloudwithdjango, Django, Deploy a Django web app to Python Anywhere, Django deployment, Deploy a Django web app, Back end development, Web developer, Django developer, Django web developer, Django web development, Deployment, Python Anywhere, Deploy a Python app to Python Anywhere, Python, Learn Django, Django for beginners, Deploy a Python app, Python developer, Python programmer, Django programmer, Free Django deployment, Deploy a Django app for free
Id: xtnUwvjOThg
Channel Id: undefined
Length: 19min 3sec (1143 seconds)
Published: Mon Nov 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.