How To Install Django Step-By-Step Tutorial

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Python is a dynamic object-oriented programming language that combines remarkable power with very clear syntax and runs on windows, linux, macintosh, palm handhelds and nokia mobile phones.

Hello to the internet and welcome to this django tutorial where we’ll discover how to install django on windows and macintosh and how to get a django server up and running.

Why and When to Use Django

Django is an easy to manage python framework. It allows you to quickly create web applications without all of the installation or dependency problems that you normally will find with other frameworks.

The Positives

  • very easy to switch databases
  • built-in admin interface
  • forms are very easy to work with
  • fully functional framework that requires nothing else
  • additional functionality with thousands of additional packages available
  • very scalable

Video: How to Install Django on Windows and Macintosh

Below the video you’ll also find the transcript and Links to jump directly to the correct part in the video

Transcript of the video above:

How to Install Django on Windows Step-by-Step

Jump to video part
This is for Windows 10 here and of course you’re going to need python so if you want to check to see if you have Python.

Hopefully you’ve been watching my learning program series which this is a continuation off and in that situation you have Python installed.

But if you want to check anyway what you want to do is you want to open up your command prompt this guy over here and you want to type in Python with a space dash dash <version>.

And hopefully you’ll see python3.4 and it’s probably best to keep python 3.4 specifically on windows because there are zero problems if you use 3.4 but if you get 3.5 a chance it should work as well as any other later versions of Python.

However if you do not have Python installed you’re going to want to go to python.org/getit/windows and you’re going to want to click on the x86 MSI installer.

And whenever you do that it’s going to install. And you’re going to click next whole bunch times and agree to a whole bunch of things and Python will be installed for you.

Specifically Python will more than likely be in your main c directory and it should be in a directory called python3.4 like you see right here.

And then what you want to do is there’s an option to automatically have Python added to your path. But sometimes that doesn’t take for some reason. So what you want to do is go over into your little start window and type in „control panel“ and click on „control panel“.

Whenever you do „control panel“ is going to open up and your going to want to click on „system and security“. Then after that you’re going to want to click on „system“. Then after that come over to „advanced system settings“ and click on that. When this guy’s gonna pop up you’re going to come down here to „environment variables“ and click on that and then you are going to come to your path right here and click on „edit“. And whenever you do – if it properly installed to your path when you install Python – you’re going to see this guy right here.

If it did not you’re going to want to come in here and say „edit“ and then put that option in and then hit „ok“ and save it and everything should be working fine now.

We’re going to close all of that stuff up and then what you want to do is you want to install pip.

So you’re just going to go into your command prompt again and type in „Python-M pipinstall -Usefacepicright“ like that. And if it doesn’t come up and say that it’s already installed it is going to install it for you and you will have pip all ready to go.

After you have that all set up what we’re going to do is create a Python virtual environment so we don’t have to worry about changing dependencies that your system may not want edited. So inside of your command prompt again you’re going to type in „pip install virtual environment“ just like that and all that will be all set up for you.
Now you’re going to want to come in here and create the virtual environment for your site in your command prompt and to do that again you’re going to type in virtual environment with a space and it normally starts off with env some people just type in env but I normally type in env with a space and then whatever I want my site to be called and just to keep this simple i typed in sight one and then you hit enter and that will be set up for it.

Now you’re going to want to activate the environment in your command prompt and to do that you’re going to want to change to your env underscore site or whatever you called it in to that specific directory and then I hit dir and you’re going to see all of these different guys right here and scripts is where we’re going to be going to next you’re going to want to change directory to scripts and then inside of the scripts directory you’re going to type in activate and hit enter and you’re going to see now we are in a virtual environment that’s what this got red means right here now what we want to do is go and install django and your command prompt again and to do so you’re just going to type in pit with space install django and everything’s going to set up for you and then you’re going to want to test that it works and the test that works you’re just going to type in Python and hit enter and then inside of here whenever these little dashes pop-up you’re gonna want to type in import space django and then django dot get underscore version and don’t forget the parentheses and whatever you do that you should see 1.10.2 or a number higher than that and if you do that you’re going to know that Django’s been installed so then you can just type in quit with two parentheses just like you see right here to exit out of the Python console now what we’re going to do is to create a sample site so I’m just going to jump backwards in our directory so i’m going to type in CD with two dashes right that and you’re going to type in django dash admin start project and then whatever you want your site to be called and come down here you’re going to see sample site as been created right there we are then going to change into the sample site directory and if you hit dir inside of there you’re going to see all this stuff pop up inside of here now sample site which is going to be another directory inside of the sample site directory is going to be where your project is going to be living
manage.PY is actually going to allow you to interact with your project.
We’re going to start our server here in a second with that you’re going to see exactly how that works and then if we go into that sample site directory you’re going to see a couple other additional files will get more specifically into these files later on but basically this guy right here this in net is just going to tell python that this is a Python package and settings which is this guy up here has all the settings for your django project URLs.PY is sort of a table contents for your project and then wsgi.PY is going to serve your project and we’ll get into all of these guys in detail pretty much in the next tutorial so now all you need to do after you have all that setup is to start your server you’re going to want to jump backwards into the sample site directory we have right here and specifically you’re looking for manage that py and you start server you’re going to type in Python manage.py runserver and if nothing goes wrong don’t worry about any of these migration things and all that stuff right here we’re just checking to make sure everything is all set up and if you do so it’s going to tell you the localhost this is localhost 127 thought 0 dot 0 dot one that is localhost on every single computer and then you’re just going to want to open up your browser to this specific address where you can just type in localhost colon 8080 browser and if you do you’re going to see it worked and there you go and you can see right here it says localhost colon 8080 so that is how to setup a django on  windows and the next part of the tutorial will start creating web  applications.

How to Install Django on Macintosh

Jump to video part
When you setup Django on a Macintosh chances are you’re going to have numerous different versions of Python running inside of this guy so what we’re going to do here is we are going to check or Python version so we’re just going to type in Python dash dash version just like for you can see here that I have python 2.7 pops up inside of there and if you have python3 installed your instead going to type in Python 3 dash version and if that shows up all perfectly fine and you don’t need to install Python otherwise you’re going to have to jump over to the Pythons tight and install it and you’re going to need at least python 3.4 or Python five now to be safe back and I know for a fact i can use Python

3.5 on a Macintosh without any problem you can use 3.4 or 3.5 doesn’t really matter but you have to use one or the other and you’re just going to come over here and click on download and then you are going to hit next a whole bunch times and agreed all kinds of different things and after you do that Python will be installed and you’re going to go back into your terminal and you’re going to check if pip has been installed or not and to do so you’re going to type in pip and version right like this and you’re going to see that it has been installed and you all should look to see that it is installed with your Python 3.5 which is what we’re going to use in this situation or 3.4 depends on whatever you chose to do if pip is not stalled or you get an error message what you’re going to want to do is install it and it’s very easy to install just going to type in sudo easy install it and you’re going to hit enter a whole bunch of times and that’s going to install i can just do this right here you’re going to your password that I and it out so there you go pitt has been installed so let’s clear that out now what you’re going to want to do is type in your terminal to install django and again you know pseudo pip install and this is going to be capital D chango like this that the DA is that a don’t worry about any of this stuff because it says the requirement already has been satisfied if it hasn’t been you’re going to get a completely different message and it’s going to say that django has been installed now what we need to do is just check that django has been installed so remember i’m going to be using Python 3 someone to type in
 Python 3 like this i’m going to say import and import Django like that and then i’m going to type in Django get version and you’re going to see that it pops back and everything is fine alright so you’re going to want to look for a number that’s like one point 10 or higher ok and to get out of the interactive console you just typing quit like that and you know that everything has been set up properly now i am going to come in here and create a sample site so let’s see what director min and there that looks perfectly fine so let’s say that I want to install in this specific directory you’re going to have to change to whatever director you want to install two and i want to create a sample site here so I’m gonna go django dash admin start project and i’ll call this sample site and then go LS and you’re now going to see the sample start right there so I’m going to change into the sample site pls you’re going to see managed rpy you’re also going to see the main directory right here i can change into my sample site directory and take a look at everything they have right here once again i talked about this in the windows part of the tutorial but you didn’t see that what this is going to do is tell python that this is a Python package this guy right here is going to have all the settings for django project we’ll get more into that later on this guy’s going to be a sort of table of contents for project which you will see and this guy is going to serve our project up for us now what I want to do is jump backwards into the previous directory and I want to go in here and start my server and to do so i’m just going to type in Python 3 manage py which is that guy right there and run server and whenever i do going to have a whole bunch of things you don’t worry about that everything should be working fun i’m going to copy this which is my localhost open up a browser paste this inside of here and run it and you can see right there it works.

Congratulations on your first django powered page!

Please leave your questions and comments below and share this tutorial with your friends and colleges on the social sites of your choice.

Find code and transcipt here

Copyright by Derek Banas. All credits go to https://www.youtube.com/channel/UCwRXb5dUK4cvsHbx-rGzSgw

See also his video on how to create an application with django for administrating and running polls and surveys here Django Tutorial 5 – How to create website and database for polls and surveys

Kommentar verfassen