First step :
Open your terminal
Second step:
Move to Documents section of your Ubuntu OS account by typing the following command in your terminal:
cd Documents
Third step :
Create a directory named python (or whatever name you wish) in the Documents section:
Fourth step :
After you have created the directory “python” , you will now move into that directory created under Document section by typing the following command in terminal :
cd python
Fifth step :
Now, you need to install Python setup tools and for that type the following in your terminal:
sudo apt-get install python-setuptools
Sixth step :
Now you need to install easy_setup to create your own virtualenv, which allows you to have your own references , paths and projects all at one place on your system and thereby avoids clashing of your django projects with your other system folder and projects. So to do that , type the following command in your terminal
sudo easy_install virtualenv==1.10.1
Seventh step :
Now, after you have installed the virtual environment , you can create a folder in it where in you can run your django project and for that , type the following in terminal :
virtualenv --no-site-packages whatever_name_you_wish_to_choose
Here , I have named it as django-kruthika. We use the --no-site-packages , while creating the folder so that we do not include the site-packages of the python2.7 installed in the system.So thereby , you are trying to customise the contents of your folder.
Eighth step :
Now that you have created your virtual environment and assigned the name to it as well, you will need to activate this virtual environment to start pumping in all your django project into this virtual environment. For that , type the following in your terminal :
source django-kruthika/bin/activate
Now you will be able to see as shown in the above screenshot.
Ninth step :
Now you will be moving inside of the virtual environment you have created , here I have named mine as django-kruthika , as mentioned before .Type the following command in your terminal :
cd django-kruthika
Tenth step :
Now , you will install django in the virtual environment you have created all this while , by typing the following in your terminal :
easy_install Django
Eleventh step:
Now when you type in ls -l bin/ , you will be able to see the following and these are what has been installed all this while .
Now that you can see django-admin.py in the bin folder there, you will use it to create your first django project in the virtual environment you have created all this while.
Type the following to create your django project and name it as you wish :
django-admin.py startproject testproject
testproject is the name i have given to the django project ,for example here.
After you have created your testproject , you move into it by using :
cd testproject
Twelfth step :
To go ahead and start running the project you have created , first check out the contents of the testproject by using ls -l command :
use the manage.py displayed on the screen to run your server.
Type the following command to start server :
python manage.py runserver
The following will be displayed :
Validating models...
0 errors found
July 01, 2014 - 21:40:39
Django version 1.6.5, using settings 'testproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
“It worked !
Congratulation on your first Django-powered page” :)
If you wish to deactivate the virtual environment, type the following on your terminal screen :
deactivate
No comments:
Post a Comment