the demo source code can be downloaded in github.
git@github.com:aaaaatoz/djangoweb.git
git@github.com:aaaaatoz/djangoweb.git
Download and Install Django
Django is the most popular Python-based web
framework (https://www.djangoproject.com/),
in this serial blogs, we are going to setup a website using Django step by step
Django can be downloaded from the official website,
the current version is 1.6 but in the blog, we will use 1.5.5
for demonstration.
When Django is downloaded, unzip the file
and you will get the files as below:
Then we will use the traditional python
command to install the django infrastructure
#python setup.py install
After a few mins, you will get the Django
framework installed. To test if it is ready just type
[root@hadoop1 Django-1.5.5 ]#
which django-admin.py
/usr/bin/django-admin.py
Setup a Project
Setup a Project and Application for your
website
In Django 1.5, project is the framework and
application is the web container. We will navigate to a proper location and
create a project as
#django-admin.py startproject djangoweb
You will find a directory called djangoweb
has been created. In side the directory, there is a directory with the same
name (djangoweb) and a manage.py file
Setup an Application
Now, make sure you are in the djangoweb (project
not the subdirectory) directory and create an application called mysite by the
below commands:
#django-admin.py startapp mysite
You will see a dictory called mysite has
been created. Now You djangoweb project should look like:
Run Django Web Framework
We will explain the files and their function in the next a few blogs but now let’s enjoy Django by the command
#python manage.py runserver 0.0.0 .0:8080
There should be no error and the web server
is ready to serve the request.
Try using web browser to access it and you
will see an Django Welcome page.
No comments:
Post a Comment