diff options
author | Mike Crute <mcrute@gmail.com> | 2012-10-24 16:59:46 -0400 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2012-10-24 17:03:08 -0400 |
commit | 3584f33f468ac027390b6312e93b2b55d06da740 (patch) | |
tree | 7f501f787e9e6708a93155bea55a2554317941af | |
parent | ebffa435ca99b24eaecebb7a58b76f28a3249a49 (diff) | |
download | django-precompiler-3584f33f468ac027390b6312e93b2b55d06da740.tar.bz2 django-precompiler-3584f33f468ac027390b6312e93b2b55d06da740.tar.xz django-precompiler-3584f33f468ac027390b6312e93b2b55d06da740.zip |
First steps
-rw-r--r-- | README.md | 34 | ||||
-rw-r--r-- | codemash/__init__.py | 0 | ||||
-rw-r--r-- | codemash/settings.py | 158 | ||||
-rw-r--r-- | codemash/templates/index.html | 24 | ||||
-rw-r--r-- | codemash/urls.py | 18 | ||||
-rw-r--r-- | codemash/wsgi.py | 28 | ||||
-rwxr-xr-x | manage.py | 10 | ||||
-rw-r--r-- | requirements.txt | 1 |
8 files changed, 272 insertions, 1 deletions
@@ -1 +1,33 @@ | |||
1 | Hello World! | 1 | ================================ |
2 | CodeMash 2012 Django Precompiler | ||
3 | ================================ | ||
4 | |||
5 | $ virtualenv django-precompiler | ||
6 | $ cd django-precompiler | ||
7 | $ source bin/activate | ||
8 | $ git init src | ||
9 | $ cd src | ||
10 | |||
11 | create requirements.txt | ||
12 | |||
13 | $ pip install -r requirements.txt | ||
14 | |||
15 | $ django-admin.py startproject codemash | ||
16 | $ mv codemash/ codemash-base | ||
17 | $ mv codemash-base/* . | ||
18 | $ rm -rf codemash-base/ | ||
19 | $ chmod +x manage.py | ||
20 | $ ./manage.py runserver | ||
21 | |||
22 | yay, django default page! now let's setup a template | ||
23 | |||
24 | $ mkdir codemash/templates | ||
25 | |||
26 | create codemash/templates/index.html | ||
27 | |||
28 | edit codemash/settings.py | ||
29 | - import os | ||
30 | - add PROJECT_DIR | ||
31 | - update TEMPLATE_DIRS | ||
32 | |||
33 | edit codemash/urls.py | ||
diff --git a/codemash/__init__.py b/codemash/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codemash/__init__.py | |||
diff --git a/codemash/settings.py b/codemash/settings.py new file mode 100644 index 0000000..31824f4 --- /dev/null +++ b/codemash/settings.py | |||
@@ -0,0 +1,158 @@ | |||
1 | # Django settings for codemash project. | ||
2 | import os | ||
3 | |||
4 | PROJECT_DIR = os.path.dirname(__file__) | ||
5 | |||
6 | DEBUG = True | ||
7 | TEMPLATE_DEBUG = DEBUG | ||
8 | |||
9 | ADMINS = ( | ||
10 | # ('Your Name', 'your_email@example.com'), | ||
11 | ) | ||
12 | |||
13 | MANAGERS = ADMINS | ||
14 | |||
15 | DATABASES = { | ||
16 | 'default': { | ||
17 | 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. | ||
18 | 'NAME': '', # Or path to database file if using sqlite3. | ||
19 | 'USER': '', # Not used with sqlite3. | ||
20 | 'PASSWORD': '', # Not used with sqlite3. | ||
21 | 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. | ||
22 | 'PORT': '', # Set to empty string for default. Not used with sqlite3. | ||
23 | } | ||
24 | } | ||
25 | |||
26 | # Local time zone for this installation. Choices can be found here: | ||
27 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | ||
28 | # although not all choices may be available on all operating systems. | ||
29 | # On Unix systems, a value of None will cause Django to use the same | ||
30 | # timezone as the operating system. | ||
31 | # If running in a Windows environment this must be set to the same as your | ||
32 | # system time zone. | ||
33 | TIME_ZONE = 'America/Chicago' | ||
34 | |||
35 | # Language code for this installation. All choices can be found here: | ||
36 | # http://www.i18nguy.com/unicode/language-identifiers.html | ||
37 | LANGUAGE_CODE = 'en-us' | ||
38 | |||
39 | SITE_ID = 1 | ||
40 | |||
41 | # If you set this to False, Django will make some optimizations so as not | ||
42 | # to load the internationalization machinery. | ||
43 | USE_I18N = True | ||
44 | |||
45 | # If you set this to False, Django will not format dates, numbers and | ||
46 | # calendars according to the current locale. | ||
47 | USE_L10N = True | ||
48 | |||
49 | # If you set this to False, Django will not use timezone-aware datetimes. | ||
50 | USE_TZ = True | ||
51 | |||
52 | # Absolute filesystem path to the directory that will hold user-uploaded files. | ||
53 | # Example: "/home/media/media.lawrence.com/media/" | ||
54 | MEDIA_ROOT = '' | ||
55 | |||
56 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a | ||
57 | # trailing slash. | ||
58 | # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" | ||
59 | MEDIA_URL = '' | ||
60 | |||
61 | # Absolute path to the directory static files should be collected to. | ||
62 | # Don't put anything in this directory yourself; store your static files | ||
63 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. | ||
64 | # Example: "/home/media/media.lawrence.com/static/" | ||
65 | STATIC_ROOT = '' | ||
66 | |||
67 | # URL prefix for static files. | ||
68 | # Example: "http://media.lawrence.com/static/" | ||
69 | STATIC_URL = '/static/' | ||
70 | |||
71 | # Additional locations of static files | ||
72 | STATICFILES_DIRS = ( | ||
73 | # Put strings here, like "/home/html/static" or "C:/www/django/static". | ||
74 | # Always use forward slashes, even on Windows. | ||
75 | # Don't forget to use absolute paths, not relative paths. | ||
76 | ) | ||
77 | |||
78 | # List of finder classes that know how to find static files in | ||
79 | # various locations. | ||
80 | STATICFILES_FINDERS = ( | ||
81 | 'django.contrib.staticfiles.finders.FileSystemFinder', | ||
82 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', | ||
83 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder', | ||
84 | ) | ||
85 | |||
86 | # Make this unique, and don't share it with anybody. | ||
87 | SECRET_KEY = 'v%l)h6^+4q8fp$f2^9!7a+_k43^j=flyc(ejbq$-)a6^8p4enk' | ||
88 | |||
89 | # List of callables that know how to import templates from various sources. | ||
90 | TEMPLATE_LOADERS = ( | ||
91 | 'django.template.loaders.filesystem.Loader', | ||
92 | 'django.template.loaders.app_directories.Loader', | ||
93 | # 'django.template.loaders.eggs.Loader', | ||
94 | ) | ||
95 | |||
96 | MIDDLEWARE_CLASSES = ( | ||
97 | 'django.middleware.common.CommonMiddleware', | ||
98 | 'django.contrib.sessions.middleware.SessionMiddleware', | ||
99 | 'django.middleware.csrf.CsrfViewMiddleware', | ||
100 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
101 | 'django.contrib.messages.middleware.MessageMiddleware', | ||
102 | # Uncomment the next line for simple clickjacking protection: | ||
103 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
104 | ) | ||
105 | |||
106 | ROOT_URLCONF = 'codemash.urls' | ||
107 | |||
108 | # Python dotted path to the WSGI application used by Django's runserver. | ||
109 | WSGI_APPLICATION = 'codemash.wsgi.application' | ||
110 | |||
111 | TEMPLATE_DIRS = ( | ||
112 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | ||
113 | # Always use forward slashes, even on Windows. | ||
114 | # Don't forget to use absolute paths, not relative paths. | ||
115 | os.path.join(PROJECT_DIR, 'templates'), | ||
116 | ) | ||
117 | |||
118 | INSTALLED_APPS = ( | ||
119 | 'django.contrib.auth', | ||
120 | 'django.contrib.contenttypes', | ||
121 | 'django.contrib.sessions', | ||
122 | 'django.contrib.sites', | ||
123 | 'django.contrib.messages', | ||
124 | 'django.contrib.staticfiles', | ||
125 | # Uncomment the next line to enable the admin: | ||
126 | # 'django.contrib.admin', | ||
127 | # Uncomment the next line to enable admin documentation: | ||
128 | # 'django.contrib.admindocs', | ||
129 | ) | ||
130 | |||
131 | # A sample logging configuration. The only tangible logging | ||
132 | # performed by this configuration is to send an email to | ||
133 | # the site admins on every HTTP 500 error when DEBUG=False. | ||
134 | # See http://docs.djangoproject.com/en/dev/topics/logging for | ||
135 | # more details on how to customize your logging configuration. | ||
136 | LOGGING = { | ||
137 | 'version': 1, | ||
138 | 'disable_existing_loggers': False, | ||
139 | 'filters': { | ||
140 | 'require_debug_false': { | ||
141 | '()': 'django.utils.log.RequireDebugFalse' | ||
142 | } | ||
143 | }, | ||
144 | 'handlers': { | ||
145 | 'mail_admins': { | ||
146 | 'level': 'ERROR', | ||
147 | 'filters': ['require_debug_false'], | ||
148 | 'class': 'django.utils.log.AdminEmailHandler' | ||
149 | } | ||
150 | }, | ||
151 | 'loggers': { | ||
152 | 'django.request': { | ||
153 | 'handlers': ['mail_admins'], | ||
154 | 'level': 'ERROR', | ||
155 | 'propagate': True, | ||
156 | }, | ||
157 | } | ||
158 | } | ||
diff --git a/codemash/templates/index.html b/codemash/templates/index.html new file mode 100644 index 0000000..c54237f --- /dev/null +++ b/codemash/templates/index.html | |||
@@ -0,0 +1,24 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <html lang="en"> | ||
3 | <head> | ||
4 | <meta http-equiv="content-type" content="text/html; charset=utf-8"> | ||
5 | <style type="text/css"> | ||
6 | html * { padding:0; margin:0; } | ||
7 | body * { padding:10px 20px; } | ||
8 | body * * { padding:0; } | ||
9 | body { font:small sans-serif; } | ||
10 | body>div { border-bottom:1px solid #ddd; } | ||
11 | h1 { font-weight:normal; } | ||
12 | h2 { margin-bottom:.8em; } | ||
13 | #summary { background: #e0ebff; } | ||
14 | #summary h2 { font-weight: normal; color: #666; } | ||
15 | </style> | ||
16 | </head> | ||
17 | |||
18 | <body> | ||
19 | <div id="summary"> | ||
20 | <h1>It worked!</h1> | ||
21 | <h2>Congratulations on your second Django-powered page.</h2> | ||
22 | </div> | ||
23 | </body> | ||
24 | </html> | ||
diff --git a/codemash/urls.py b/codemash/urls.py new file mode 100644 index 0000000..6889381 --- /dev/null +++ b/codemash/urls.py | |||
@@ -0,0 +1,18 @@ | |||
1 | from django.conf.urls import patterns, include, url | ||
2 | from django.views.generic import TemplateView | ||
3 | |||
4 | # Uncomment the next two lines to enable the admin: | ||
5 | # from django.contrib import admin | ||
6 | # admin.autodiscover() | ||
7 | |||
8 | urlpatterns = patterns('', | ||
9 | # Examples: | ||
10 | url(r'^$', TemplateView.as_view(template_name="index.html"), name='home'), | ||
11 | # url(r'^codemash/', include('codemash.foo.urls')), | ||
12 | |||
13 | # Uncomment the admin/doc line below to enable admin documentation: | ||
14 | # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), | ||
15 | |||
16 | # Uncomment the next line to enable the admin: | ||
17 | # url(r'^admin/', include(admin.site.urls)), | ||
18 | ) | ||
diff --git a/codemash/wsgi.py b/codemash/wsgi.py new file mode 100644 index 0000000..7e9b6ef --- /dev/null +++ b/codemash/wsgi.py | |||
@@ -0,0 +1,28 @@ | |||
1 | """ | ||
2 | WSGI config for codemash project. | ||
3 | |||
4 | This module contains the WSGI application used by Django's development server | ||
5 | and any production WSGI deployments. It should expose a module-level variable | ||
6 | named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover | ||
7 | this application via the ``WSGI_APPLICATION`` setting. | ||
8 | |||
9 | Usually you will have the standard Django WSGI application here, but it also | ||
10 | might make sense to replace the whole Django WSGI application with a custom one | ||
11 | that later delegates to the Django one. For example, you could introduce WSGI | ||
12 | middleware here, or combine a Django application with an application of another | ||
13 | framework. | ||
14 | |||
15 | """ | ||
16 | import os | ||
17 | |||
18 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codemash.settings") | ||
19 | |||
20 | # This application object is used by any WSGI server configured to use this | ||
21 | # file. This includes Django's development server, if the WSGI_APPLICATION | ||
22 | # setting points here. | ||
23 | from django.core.wsgi import get_wsgi_application | ||
24 | application = get_wsgi_application() | ||
25 | |||
26 | # Apply WSGI middleware here. | ||
27 | # from helloworld.wsgi import HelloWorldApplication | ||
28 | # application = HelloWorldApplication(application) | ||
diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..1393d93 --- /dev/null +++ b/manage.py | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/usr/bin/env python | ||
2 | import os | ||
3 | import sys | ||
4 | |||
5 | if __name__ == "__main__": | ||
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codemash.settings") | ||
7 | |||
8 | from django.core.management import execute_from_command_line | ||
9 | |||
10 | execute_from_command_line(sys.argv) | ||
diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e916d7e --- /dev/null +++ b/requirements.txt | |||
@@ -0,0 +1 @@ | |||
Django==1.4 | |||