Skip to content

Instantly share code, notes, and snippets.

@yoniLavi
Last active February 27, 2017 16:19
Show Gist options
  • Select an option

  • Save yoniLavi/6fda414c42dadb08a6070c5c7108d6b6 to your computer and use it in GitHub Desktop.

Select an option

Save yoniLavi/6fda414c42dadb08a6070c5c7108d6b6 to your computer and use it in GitHub Desktop.
Example of simplest possible Django Project
# Based on the book 'Lightweight Django'
# by Mark Lavin & Julia Elman
# See the following Repo for this example broken into multiple files.
# https://github.com/richardadalton/djangolight
from django.core.management import execute_from_command_line
from django.conf import settings
from django.conf.urls import url
from django.http import HttpResponse
# SETTINGS
settings.configure(
DEBUG=True,
SECRET_KEY='thisisthesecretkey',
ROOT_URLCONF=__name__,
MIDDLEWARE_CLASSES=('django.middleware.common.CommonMiddleware',),
)
# VIEWS
def index(request):
return HttpResponse('Hello World')
# URLS
urlpatterns = (
url(r'^$', index),
)
# MANAGE.PY Command Line Handler
if __name__ == "__main__":
execute_from_command_line(['', 'runserver'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment