Django doesn’t really need a hello world style introduction, its documentation speaks for itself.
But this is what “Hello, world!” in Django looks like to me. I hate boilerplate and I love reducing software down to its core components; just enough to start the server.
from setuptools import setup setup( name='hello', )
Django==1.4.1 -e .
from hello import urls DEBUG = True ROOT_URLCONF = urls
from django.conf.urls import patterns urlpatterns = patterns( '', (r'', 'hello.views.index'), )
from django.http import HttpResponse import datetime # Based on https://docs.djangoproject.com/en/1.4/topics/http/views/ def index(request): """ This function takes a Django request object and returns a 'Hello World' style response, by wrapping some HTML in a Django response object. """ now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>" % now return HttpResponse(html)