Write Django application

Write Django application

Creating a project

If this is your first time using Django, you’ll have to take care of some initial setup. Namely, you’ll need to auto-generate some code that establishes a Django project – a collection of settings for an instance of Django, including database configuration, Django-specific options and application-specific settings.

From the command line, cd into a directory where you’d like to store your code, then run the command

django-admin.py startproject mysite

This will create a mysite directory in your current directory.

Let’s look at what startproject created:
mysite/
__init__.py
manage.py
settings.py
urls.py

These files are:
__init__.py: An empty file that tells Python that this directory should be considered a Python package.
manage.py: A command-line utility that lets you interact with this Django project in various ways.
settings.py: Settings/configuration for this Django project.
urls.py: The URL declarations for this Django project; a "table of contents" of your Django-powered site.

By default, the runserver command starts the development server on the internal IP at port 8000.

If you want to change the server's port, pass it as a command-line argument. For instance, this command starts the server on port 8080:


cd mysite

python manage.py runserver 8080

If you want to change the server's IP, pass it along with the port. So to listen on all public IPs (useful if you want to show off your work on other computers), use:


python manage.py runserver 79.133.200.37:8000

Full docs for the development server can be found in the runserver reference.

output :

Validating models...
0 errors found

Django version 1.2.4, using settings 'mysite.settings'
 Development server is running at http://ssh.hypeshell.com:8000/
Quit the server with CONTROL-C.
[08/Aug/2011 11:19:49] "GET / HTTP/1.1" 200 2051

and now you can check server

http://ssh.hypeshell.com:8000/