It’s been along time i’m not writing tutorial on my blog, since i’m struggling to learn some languages those are Python and Ruby, and also i’ve learned some frameworks of them those are Django and Rails. Why?? i have two reasons to answer that question, first i’ve assigned to do self learning on my office, and the second one i’m curious on that. This time i’m talking about Python, I think Python language has a good code structure because we have to careful in writing Python code, in fact the indentation take an effect to the interpreter, our codes will be compiled error if we are wrong to set the indentation. But the advantage is our codes will be structured and it will be easier to read. It will be easy to write Python codes if you have a good IDE that has formater feature for python. But now, i’m going to give you the way to install Python and Django on your windows machine. Django is one of the framework that using Python as a base language and I think Django is the most popular one than the others.
Prerequisite : –
Python Installation :
Now, Lets get the ball rolling :
1st. First, we have to download the latest Python Installer (as per may 2015 the version is 3.4.3).
2nd. Click the installer, and set to the default directory (C:\Python34) and wait until the progress is done.
Add Path on Windows Environment Variables :
1st. Right click on My Computer.
2nd. Click Advanced system settings.
3th. Click Environment Variables button.
4th. Click PATH on Variable column, then append this path.
note : adjust the version and take a look the delimiter “;”.
Check everything is running well :
1st. Open the windows command prompt.
2nd. Type “Python” on your command prompt, if you are seeing image below that means python is already installed on your windows.
note : the path is working when you open the command prompt after you already set the path, don’t use your recent command prompt before you set the path.
Django Installation :
1st. First, we have to download the latest Django Framework (as per may 2015 the version is 1.8.1).
2nd. After the file has been downloaded, then extract to C:\Django.
3th. Open command prompt on that directory then type python setup.ph install and wait until the progress is done.
4th. Type python again, then type import django (if there is no message appears that mean Django has been installed properly).
5th. You can quit from python command line using Ctrl+z then enter or type exit() then enter.
Create Django Project :
To ensure the python and django is already working properly, let’s create the Django project.
1st. Create folder under directory C:\Django, you can name it C:\Django\projects, C:\Django\works, or anything you want.
2nd. Set command prompt to your projects directory, to create Django site you only need to type django-admin startproject [project name], (as for example django-admin startproject newsite).
3th. Now, your newsite project has been generated on your projects directory and named as you decide.
4th. Let’s running the server, ensure your command prompt has been set on your project folder.
5th. To run Django server you only need to type python manage.py runserver (the default port is 8000), if you want to run server on another port you only need to type python manage.py runserver 8087 and the server is running on port 8087.
6th. Open browser and go to url http://localhost:8087 or http://127.0.0.1:8087.
Congratulation, now you are having Python and Django on your windows machine and you know how to create project and how to run the Django server. I hope next time, i can write the tutorial using Django Framework.