Created
February 27, 2017 07:29
-
-
Save richardadalton/4dbf2ec485188e7a06ffd209a374175e to your computer and use it in GitHub Desktop.
Example of simplest possible Django Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
import sys | |
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', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
), | |
) | |
# 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(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment