Add codetemplates directory; add Django project template
This commit is contained in:
parent
2ea4c34811
commit
23996c860b
11 changed files with 180 additions and 0 deletions
3
codetemplates/django_project/.env
Normal file
3
codetemplates/django_project/.env
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
DATABASE_URL=sqlite://localhost/local.db
|
||||||
|
SECRET_KEY={{ secret_key }}
|
||||||
|
DEBUG=True
|
18
codetemplates/django_project/Makefile
Normal file
18
codetemplates/django_project/Makefile
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
MANAGEPY=honcho run -- env/bin/python manage.py
|
||||||
|
|
||||||
|
update:
|
||||||
|
virtualenv env
|
||||||
|
env/bin/pip install -r requirements.txt
|
||||||
|
$(MANAGEPY) syncdb
|
||||||
|
|
||||||
|
migrate:
|
||||||
|
$(MANAGEPY) migrate
|
||||||
|
|
||||||
|
run: update
|
||||||
|
$(MANAGEPY) runserver 0.0.0.0:8000
|
||||||
|
|
||||||
|
shell: update
|
||||||
|
$(MANAGEPY) shell
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
git push heroku master
|
1
codetemplates/django_project/Procfile
Normal file
1
codetemplates/django_project/Procfile
Normal file
|
@ -0,0 +1 @@
|
||||||
|
web: python manage.py run_gunicorn -w4 -b 0.0.0.0:$PORT
|
3
codetemplates/django_project/codetemplates
Normal file
3
codetemplates/django_project/codetemplates
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
DATABASE_URL=sqlite://localhost/local.db
|
||||||
|
SECRET_KEY={{ secret_key }}
|
||||||
|
DEBUG=True
|
8
codetemplates/django_project/manage.py
Normal file
8
codetemplates/django_project/manage.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
execute_from_command_line(sys.argv)
|
0
codetemplates/django_project/project_name/__init__.py
Normal file
0
codetemplates/django_project/project_name/__init__.py
Normal file
3
codetemplates/django_project/project_name/models.py
Normal file
3
codetemplates/django_project/project_name/models.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
16
codetemplates/django_project/project_name/tests.py
Normal file
16
codetemplates/django_project/project_name/tests.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
This file demonstrates writing tests using the unittest module. These will pass
|
||||||
|
when you run "manage.py test".
|
||||||
|
|
||||||
|
Replace this with more appropriate tests for your application.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleTest(TestCase):
|
||||||
|
def test_basic_addition(self):
|
||||||
|
"""
|
||||||
|
Tests that 1 + 1 always equals 2.
|
||||||
|
"""
|
||||||
|
self.assertEqual(1 + 1, 2)
|
1
codetemplates/django_project/project_name/views.py
Normal file
1
codetemplates/django_project/project_name/views.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Create your views here.
|
111
codetemplates/django_project/settings.py
Normal file
111
codetemplates/django_project/settings.py
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
# Settings for {{ project_name }}.
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
DEBUG = os.environ.get('DEBUG', False)
|
||||||
|
TEMPLATE_DEBUG = DEBUG
|
||||||
|
|
||||||
|
ADMINS = ()
|
||||||
|
MANAGERS = ADMINS
|
||||||
|
|
||||||
|
import dj_database_url
|
||||||
|
DATABASES = {'default': dj_database_url.config()}
|
||||||
|
|
||||||
|
SITE_ID = 1
|
||||||
|
|
||||||
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
USE_I18N = True
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
TIME_ZONE = 'America/Los_Angeles'
|
||||||
|
|
||||||
|
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
|
||||||
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
|
STATIC_ROOT = os.path.join(PROJECT_DIR, 'collected-static')
|
||||||
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
STATICFILES_DIRS = (
|
||||||
|
os.path.join(PROJECT_DIR, 'static'),
|
||||||
|
)
|
||||||
|
|
||||||
|
STATICFILES_FINDERS = (
|
||||||
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||||
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||||
|
)
|
||||||
|
|
||||||
|
TEMPLATE_LOADERS = (
|
||||||
|
'django.template.loaders.filesystem.Loader',
|
||||||
|
'django.template.loaders.app_directories.Loader',
|
||||||
|
)
|
||||||
|
|
||||||
|
MIDDLEWARE_CLASSES = (
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
)
|
||||||
|
|
||||||
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.core.context_processors.i18n',
|
||||||
|
'django.core.context_processors.request',
|
||||||
|
'django.core.context_processors.media',
|
||||||
|
'django.core.context_processors.static',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
)
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'urls'
|
||||||
|
|
||||||
|
TEMPLATE_DIRS = (
|
||||||
|
os.path.join(PROJECT_DIR, 'templates'),
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALLED_APPS = (
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.sites',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
# Custom apps below here.
|
||||||
|
'{{ project_name }}',
|
||||||
|
)
|
||||||
|
|
||||||
|
if DEBUG:
|
||||||
|
INSTALLED_APPS += ('django.contrib.admin',)
|
||||||
|
|
||||||
|
LOGGING = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': False,
|
||||||
|
'handlers': {
|
||||||
|
'console': {
|
||||||
|
'level': 'DEBUG' if DEBUG else 'INFO',
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'loggers': {
|
||||||
|
'': {
|
||||||
|
'handlers': ['console'],
|
||||||
|
'level': 'INFO',
|
||||||
|
'propagate': True,
|
||||||
|
},
|
||||||
|
'{{ project_name }}': {
|
||||||
|
'handlers': ['console'],
|
||||||
|
'level': 'DEBUG' if DEBUG else 'INFO',
|
||||||
|
'propagate': True,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Environment
|
||||||
|
#
|
||||||
|
|
||||||
|
assert 'SECRET_KEY' in os.environ, 'Set SECRET_KEY in your .env file!'
|
||||||
|
SECRET_KEY = os.environ['SECRET_KEY']
|
16
codetemplates/django_project/urls.py
Normal file
16
codetemplates/django_project/urls.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from django.conf import settings
|
||||||
|
from django.conf.urls import patterns, include, url
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = patterns('',
|
||||||
|
url(r'', include('{{ project_name }}.urls')),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
from django.contrib import admin
|
||||||
|
admin.autodiscover()
|
||||||
|
urlpatterns += patterns('',
|
||||||
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue