# follow the usual steps to install python 2.7.3 and django 1.4.2 , then setup a project and app:
django-admin.py startproject helloworld
chmod +x helloworld/manage.py
helloworld/manage.py startapp hi
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
vi helloworld/helloworld/settings.py
...
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'hi',
)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# note this handles two different URL patterns: 192.168.1.2/ and 192.168.1.2/hi
# when the regex is empty or "begins with hi" then it returns the function index from the view in the hello application
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
(r'^$','hi.views.index'),
(r'^hi','hello.views.index'),
)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
vi helloworld/hi/views.py
from django.http import HttpResponse
def index(request):
return HttpResponse("hi")
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You can verify the python django app is running using the dev web engine
./manage.py runserver 0.0.0.0:8888