Python Web Development | Web Development Using Django | Python Django Tutorial | Edureka

Hey guys, welcome back to a new sessionfrom Edureka. My name is Wajiha. And in this session, we will be learning somethingvery interesting which is web development apply python. So before we begin justmake sure you subscribe to our Channel and hitthe Bell icon to stay updated with all the latestEdureka videos. Coming back towards the session. Let’s take a quick look atall that’s in store over here for you guys to begin with. We shall first coversome Basics about Python and then we shall look at why python is used forweb development following this we shall take a look at some of the importantweb development libraries or Frameworks of pythonin today’s time. I’ll be usingthe Django framework to develop a sample website. So let’s just look at whatthe enticing combining of python and Djangooffers us after that. We shall move on straight away. Install Django and finally, I’ll be registering youhow to create a sample website from scratch.So I hope everyone’sclear with this. So now let’s move ontowards the first topic of this session to brush upa few Basics about python people. Python is an interpretedhigh-level language, which can be treatedin an object-oriented sequential or a procedural way. It also provides high levelbuilt in data organizations, who the hell is mergedwith Dynamic typing and dynamic binding semantics that make it very attractive for work developmentweb occurrence is nothing but the taskof developing websites that can be hosted bythe internet it varies from simple pageto complex websites.For example, Facebook Etc. Now that we’ve coveredthe basics of python. Let’s move on and attend why pythonis used for web development guys python allows youto build web applications. Dynamically. It’s a very stablelanguage it also. Mutters, you used to build multi-protocol Networkapplications the fact of python being resilient easy-to-use and it’s quick managing arejust a few concludes to mention for its worthin network developing. Now that I’ve explainedabout the features of python, let’s take a walkthrough some of the libraries that python provides for web development guys pythonprovides a number of libraries for network development.Some of the important onesare cherry pie Django web to pipe pyramid turbo paraphernaliums and flask among thesein today’s session. I’ll be usingthe Django framework. So now y’all might be wonderingwhy Django and why not any other Library Django istruly the best python library for entanglement developing. It’s written strictly in Python and it’s fast youcan create websites within a matter of a few hours. It’s fully loaded with all the required toolsto create websites and it’s very lock Beat YouTube your DropboxGoogle or in Graham all these internet Giant’srely on Jango.So with this I thinkI’ve given you fairly for why I’ve chosen Djangoover the other libraries. Okay. So guys now let’s move on to see how to install Djangobefore installing Django. You will have to install pythonon your PC’s to do that. You can go to the officialpython web site and download it from there. I’ll be depicting you guys shortly how to do the sameafter downloading python. You’ll have tofinish its installation and setup process following that I’ll be showingyou all how to set the python dwelling variable. This is done to makeyour IDE look for python as to where its invested on your PC after that you’ll haveto download pycharm and install the same on your PC.Finally. You’ll have to openthe pycharm terminal and use the command to install Django. Okay. So now let me go ontowards the browser and display y’allhow to download python as you can see on the screen. This is the officialpython web site from where you can download python. If you’re usinga Windows platform, you can download python usingthis option over here or if you are using Mac Linuxor any other operating system, you can usethe corresponding options. Once the download is completedyou will have to finish with the setup since I’ve alreadyinstalled it over here. It is not give mean install option. It time gives mean option to modify repair or uninstall this.Okay, so after installingthis on your PC go to the advanced system aims. Choose the optionof environment variables and over here choosethe new Option and give the name as python underscore residence. For the value of this variable. You’ll have to replica the road of where python has beeninstalled on your PC. To find where pythonhas been installed on your PC exactly search for Python and right-click on the sameand use open document locating, as you can see over here. It shows me whereI’ve set python now, I’ll copy this spot and I’mgoing to paste it as the best interests of the this variable and use okay.After doing that lookfor the footpath variable present in the system variablesand select edit. Go to the variable significance and towards the endof the quality. If you do not finda semicolon insert a semicolon. And after that typepython underscore home between two percentage symbols. Just like how I’ve doneit over here. Okay, so after thatjust dedicate okay. And close the installs. Once this is done. Your python locationwill be visible to your IDE to download pycharm goto the jetbrains website and download any versionof your alternative chaps. The community account is free. So you can downloadthis with ease. Okay, so I hope you are clearwith how to download and install these two. After downloading pycharm, you will have tofinish the installation and the setup process. Since it’s alreadydownloaded on my PC, So I hope everyone’s clear with how to installPython and pycharm. If you guys have any indecisions, satisfy do let me knowin the schmooze carton and my squad is here to help you.So guys, delight make sureyou’ve were in favour of our canal to find more interesting videosfrom Eddie Rekha. So as you can see over hereweb project has been created within the current directory. So after this, I’ll just open upthe terminal and over here. I’ll use the commandpip install Django. It’s going to take awhileto install Django chaps. So when you’re installing Django along with Djangothe SQL parse data base and the PYT rectified modulealso gets invested. SQL forbids is actually an on validating SQLparser for python. It provides supportfor parsing dividing and formatting SQL explanations. Now, this is actually compatible with the versionsof python from 2.7. The pyd is at module isactually a third party module that accompanies the Alston TZdatabase into python razz. It actually standsfor time area people, this Library allowsaccurate and cross-platform time zone calculations usingpython 2 extent 4 or higher.It likewise solves the issueof doubtful eras. Okay. So formerly Djangohas been installed, it will propel a sense sayingsuccessfully set Django with its versionand the explanation of the PYT that module and the SQL parsenow to cross check the installation of Django goto your command prompt. and use the command python -M Django – – version now when you usethis command it should return the explanation of Djangothat’s been installed. So I hope everyoneis getting the same. Okay. So now let’s close this. I hope everyone’s clearwith this for any roadways guys. Please do let me knowin the converse chest because my squad isalways now to assist you. So now to createa Django project within this project. I’ll use the command Django -admin start project. And I’ll establish a nameto my project.Let me give the nameas demo job. Okay. So now a demo programme has been created withinthe web project directory. Let me open this directory and here it showsthe web project that’s been created. Let me just goto the presentation mode and depict you I’ll going to see viewand I’ll hand-picked the records that I want and the terminal as you can see over here withinthe demo activity index. There’s another directorywith the same name as my job and there is a filecreated by Django called as the manage scatter py file.The subject is not py file isactually a command boundary practicality that can help you interactwith the Django project. Don’t worry people. We’ll be usingthis many a times. So you’ll getfamiliar with this. Now. Let me just openthis directory and see what’s present within itthe first document that’s created within this directory is the in it dot p y now the in it flecked p y is actuallyan empty directory which is consideredto be a package. After that. There is something called asthe directs flecked P why this actually consists of all the But unnecessary forthe current project after that, it’s URLs dot py URL start py consists of all the URL declarationsfor this project and finally the wsgi speck py file where wsgi stands forweb server Gateway interface. Now, this is actuallya calling convention people for web servers to forwardrequests to web employments or other servers. So I hope everyone’sclear on till here if you have any skepticisms do letme know in the schmooze box. Okay, so now to check if I’m able to connectfrom my project to the web server.I’ll time get into my projectusing the CD command. And after this I’ll usePython managed at py. feed server Like I told you the manage dot py5 will helpme connect to the server. So this will returnan IP address. So when you clickon that address, you will see a screenwith a projectile which is ready to take off. So congratulations chaps. Your rocket is ready to move on which means you’re all setto create your own web sites. So I know that after this everyonewould be excited to create their own websites to do so, I’ll really get back to my pycharmand picture you guys what exactly you must doto create your own websites. Okay, so to create my website, all I’m going to do is createan app within my demo activity. I’ll time return the controlto my terminal consuming Ctrl C and over here. I’ll create a brand-new appwithin my campaign. Please make a note people that one project can sanctuary number of apps which means you can includeany number of apps within your project.To create an app. I’ll use the same command which is python organize dot p yand instead of control server. I’ll use the start app commandand I’ll present a mention to my app. Let me exactly givethe appoint as demo app. So now an app has been createdwithin my activity. Let me just open this upto show you all what’s portray within this demo app. So just like how Django had created filesfor us within our assignment when we created a brand-new app Django has createdthe necessary folders for us.So this is what Django does it writesall the necessary code. And all you have to do is writeyour web site specific codes and only revise the records that are present and addyour own enters as per your preference. The first register that I’m going to open overhere is judgments dot p y and as you can see overhere Django has already imported interpret for me now. I want to usethe HTTP response function. So I’ll use from Django http. Import HTTP response, delight. Be careful withyour Spelling’s chaps. Now within this filecreate a brand-new function using the d e f key word and I’ll give the nameof the capacity as high to this function.I’ll pass one parameterwhich is request. Within this function. I’ll simply writeone return word. Using the HTTPresponse function. I actually crave this functionto return a message saying that this is the homepageof my website. I’ll merely thrown it as a cord andI’ll use the H1 tag for this. This is my home page. And I’ll close the H1 label/ H 1. So as you can seeover here pycharm has highlighted this front because I’m usingthe HTTP response function.The firstly order of my codeis not highlighted because I’m not consuming the renderfunction anywhere as of now. I will not be usingthe render function. However, I will be proving youhow to use this later on. Okay. Now I’ve createdviews for my assignment but I will not be ableto connect this document to the URL suffer py which is present in the demo app to connectviews dot p y to this URLs speck p y I’ll have to createanother URLs speck p y within the demo appdirectory and connect that URLs scattered p yto the URL stood py which is presentin the demo project.Don’t get confused chaps. I’ll be doing it over here and the video will beavailable after this in case you have any doubtsyou can go through it again. So I’ll just createa brand-new folder within the sap. It’s going to be a python file. I’ll give the nameas URL start py. And I’ll say okay this URL stoodpy is actually very similar to the URLs that py which is presentin the demo assignment document open the URLs to py presentin the demo campaign directory. And I’ll copy the from evidence which is from Djangodot URLs import part and the URL pattern list. I’ll time copy this and I’ll go to URL startpy present in my app and I’ll paste it overhere now over here since I want to map the viewsdot p y into this URL start py What I’m goingto do is use from.Which necessitates fromthe current directory. Import views and withinthe URLs pattern I is not hanker this admin path. So I’ll really remove this andI’ll leave the name as space. Because I crave this to be mappedto my homepage and over here. I’ll abuse sentiments scattered. Hi. It’s just the nameof my run and I’ll establish a call to this path. You can give any nameof your option. Let me merely give the nameas homepage residence – page. Okay. So after this what I “re going to have to” do ismap this URLs scatter p y to the URL stood py which ispresent in the demo app, so I’ll open the URL start pypresent in the demo app and over here. I’ll Create A New Pathand I’ll give an empty fibre because I wanted to be mappedto my homepage. Like I already told you all. Sorry people. I’ll have to importthe include gathering also. So from Django dot URLs, I’ll import theinclude capacity. And over here, I’m going to usethe include function.I’ll map the URL stood pypresent in my demo app. And I’ll close this. So after this, let me just goto my terminal and use Python manage speck py extended server. I’ve just made a epithet mistakethis is demo app. Okay, so as youcan see over here, it has returnedto IP address again. I’ll click on this IP address. Congratulations guysinstead of the rocket which we were appreciating previouslywhich was the default page. My website is displayingwhatever I want it to display.So this was the message I wanted to displayon my home page and it shows that this is my home page. So now I’ll get backto my pycharm and I’ll see how I can modify this pageto create a website. I’ll return the restrict backto my terminal exercising Ctrl C. So to write HTML codewithin this project. All you have to do iscreate a brand-new index within your app directory. And that will bethe templates directory.Now. These will be the templatesthat are specific to this project and insteadof glancing abroad. Django will lookinto this directory for the necessary templates. Within the templates index, I will create a new directorywith the same name as my app. Don’t get confused with this guy’s this isactually the Django convention which helps you writeProject Specific code So within this demo app, I want to writethe HTML code. So I’ll create a brand-new HTML fileto write all the HTML code that I want. I’ll really give the name asHigh Dot HTML and I’ll say okay. So as you can see over hereDjango has already written the minimum HTML code for me. I’ll exactly modify the titleto Eddie realise. You can give any designation ofyour option and within the body. I’ll exactly write Hi and after this I’ll openthe app store py file. I’ll copy the nameof this class and then go to settings scattered py present in My Demo projectand over here.I look for invested apps. Remember that wheneveryou initiate brand-new apps, you’ll have to add it overhere then within a fibre give the name of the app, which is demo app. Please be very carefulwith the spelling’s because if you make any mistakes, it’s going to shy a lotof faults and you’ll not be able to understand whyit’s throwing such inaccuracies and for beginners itsometimes gets very confusing to debug these lapses. So merely be careful over there. So let me get backto this name of my app, which is demo app scatter apps dotthe name of the class that we’ve followed from there. I’ll time paste it over here and I’ll specify a commaafter this now from here. I’ll go backto my views scatter py register and instead ofthis HTTP response. I’ll be usingthe render function. So I’ll just remove this. I’ll return yield. And I’ll specifythe request serve and then within a string I’ll specifythe HTML file which is present in the demo app.So demo app./ hi speck HTML, which is the name of my register. Guys, please write the same name which you have givento your folder. I’ll operate my serveragain after this. So python -. P y passed server. Let’s go back to our serverand find what happens. So as you can seeover here guys, the entitle has changedfrom the default address to Eddie Rekha and my home pagenow proves a theme saying hi.So I hope everyone’s clearwith everything til now now, all I’m going to do isgo back to my HTML file and do some modificationsto create my own website. So now to create my own website. I’m just going to modifythis HTML page chaps. If you’re done till here, you’ve been successful in creating a websitenow all “youve got to” do after this is specifyyour Project Specific HTML code. Let me simply prove youa few basic things that you can dousing HTML over here. So I hope everyone knowssome basics of HTML. Let me precisely changethe content from high to welcome to edu Rekha. Okay, I’ll justspecify the second line of my sheet to be some h2 tagand a new theme saying that this is my website. Let me save thisand rerun my server.I’ll just go back to my serverand I’ll reload the page. So as you can see over here, the H1 tag says welcometo edu Rica and the second. H2 tag says this is my website. So this is how you can writeyour own HTML code to your planned chaps. So now let me originate some listover here to create a list. I can either specify itto be an succession directory or an unordered listfor tell roster. I’ll have to use ol tagand for unordered register, I’ll have to usethe UL tag over here. I’ll be using the unordered list and within this listI’ll specify the listing elements.First element is Pythonand the second element. I will give usJava or something. Okay, let me savethis go back to my server and reload this sheet. So as you can seeover here people, it has createdan unordered roll over here. So now let me show y’allhow to create a table over here. So to create a table for your website youcan use the table tag. And specify whatever wording youwant for your counter in my lawsuit. I’ll simply give the width to be. 50% and I’ll close this. So within the table youcan have the TR the th and the TD labels. The TR tag is actually for the counter rows th isfor table leads and TD is for the counter columns.I’ll precisely write a Dr. Tag overhere and within this TR tag, I’ll specify the th calls. Let me exactly givethe manager as python. And I’ll impart another origin. as Java So after this, I’ll create another rowusing the TR tag. And within this I’llspecify the lines. So for that I’ll use the TD tagand I’ll time specify which IDE you can usefor Python and Java so for python youcan use pycharm. Let me only facsimile this. And for Java youcan use Eclipse. So I’ll conversion the identify frompycharm to Eclipse over here. And I will save this. So as you can see over herea table was generated but guys my tableover here does not have any territories to addborders to my table. I’ll go back to my HTML pageand over here within head.I’m going to use the style tag. And within the stackI’ll specify what strip I require for my table. Let me save thisand reload my sheet. So as you can seeover here chaps, I included the style tag and specified what kindof Border I crave. So the same way on my server over herea table has been created with a specified style to knowmore about HTML and learn how to createbeautiful websites. You can just goto the bootstrap website. And from here youcan take any code that you want for your website. So I’ll merely appearance youwhat happens when you use this. So let me just use the stylefrom the bootstrap and it should be presentwithin the head. So I’ll just paste it over here. Let me save this. I’ll go back to my serverand I’ll reload this sheet as you can see over here people using the small bit of system that was presentof the bootstrap website.My website gapes somuch more better than what it was looking before this. You can use this bootstrapwebsite to create your own beautiful websites. Okay. So with this we cometowards the end of our activity. So I hope you are clear with all that’s been coveredin this session. In case you haveany inquiries or suggestions, delight do let me knowin the comment section and I will revert to youat the earliest good bye-bye and take care. I hope you have enjoyedlistening to this video.Please be kind sufficient to like it and you can comment anyof your suspenses and queries and we will reply them at the Earliest do look outfor more videos in our playlist And subscribe to Edureka channel to learn more. Happy learning ..

As found on YouTube

Share this article

Leave a comment

Related Posts