Skip to content

Commit e7a570b

Browse files
committed
Upgrade to Django 2.0, follow Two Scoops layout
1 parent e93aabe commit e7a570b

File tree

11 files changed

+200
-0
lines changed

11 files changed

+200
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,5 @@ ENV/
101101
.mypy_cache/
102102

103103
.idea/
104+
105+
config/settings/local.py

config/__init__.py

Whitespace-only changes.

config/settings/__init__.py

Whitespace-only changes.

config/settings/base.py

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
"""
2+
Django settings for nerd_herder project.
3+
4+
Generated by 'django-admin startproject' using Django 2.0.1.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/2.0/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/2.0/ref/settings/
11+
"""
12+
13+
import os
14+
15+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = '6+35+z!)+d_u)lee=rg@%8q23hh^re=v@a0qge)a0)d=5)=$z-'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = False
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
'debug_toolbar',
41+
'nerd_herder',
42+
]
43+
44+
MIDDLEWARE = [
45+
'django.middleware.security.SecurityMiddleware',
46+
'django.contrib.sessions.middleware.SessionMiddleware',
47+
'django.middleware.common.CommonMiddleware',
48+
'django.middleware.csrf.CsrfViewMiddleware',
49+
'django.contrib.auth.middleware.AuthenticationMiddleware',
50+
'django.contrib.messages.middleware.MessageMiddleware',
51+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
52+
'debug_toolbar.middleware.DebugToolbarMiddleware',
53+
]
54+
55+
ROOT_URLCONF = 'config.urls'
56+
57+
TEMPLATES = [
58+
{
59+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
60+
'DIRS': [],
61+
'APP_DIRS': True,
62+
'OPTIONS': {
63+
'context_processors': [
64+
'django.template.context_processors.debug',
65+
'django.template.context_processors.request',
66+
'django.contrib.auth.context_processors.auth',
67+
'django.contrib.messages.context_processors.messages',
68+
],
69+
},
70+
},
71+
]
72+
73+
WSGI_APPLICATION = 'config.wsgi.application'
74+
75+
76+
# Database
77+
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
78+
79+
DATABASES = {
80+
'default': {
81+
'ENGINE': 'django.db.backends.sqlite3',
82+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
83+
}
84+
}
85+
86+
CACHES = {
87+
'default': {
88+
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
89+
}
90+
}
91+
92+
93+
# Password validation
94+
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
95+
96+
AUTH_PASSWORD_VALIDATORS = [
97+
{
98+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
99+
},
100+
{
101+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
102+
},
103+
{
104+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
105+
},
106+
{
107+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
108+
},
109+
]
110+
111+
112+
# Internationalization
113+
# https://docs.djangoproject.com/en/2.0/topics/i18n/
114+
115+
LANGUAGE_CODE = 'en-us'
116+
117+
TIME_ZONE = 'UTC'
118+
119+
USE_I18N = True
120+
121+
USE_L10N = True
122+
123+
USE_TZ = True
124+
125+
126+
# Static files (CSS, JavaScript, Images)
127+
# https://docs.djangoproject.com/en/2.0/howto/static-files/
128+
129+
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
130+
STATIC_URL = '/static/'

config/urls.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""nerd_herder URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/2.0/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path
18+
19+
urlpatterns = [
20+
path('admin/', admin.site.urls),
21+
]

config/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for nerd_herder project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
15+
16+
application = get_wsgi_application()

dev_requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-r requirements.txt
2+
3+
django-debug-toolbar==1.9.1

manage.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
7+
try:
8+
from django.core.management import execute_from_command_line
9+
except ImportError as exc:
10+
raise ImportError(
11+
"Couldn't import Django. Are you sure it's installed and "
12+
"available on your PYTHONPATH environment variable? Did you "
13+
"forget to activate a virtual environment?"
14+
) from exc
15+
execute_from_command_line(sys.argv)

nerd_herder/__init__.py

Whitespace-only changes.

nerd_herder/templates/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>$Title$</title>
6+
</head>
7+
<body>
8+
$END$
9+
</body>
10+
</html>

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Django==2.0.1
2+
psycopg2==2.7.3.2
3+
pytest==3.3.2

0 commit comments

Comments
 (0)