Skip to content

Commit f5c048a

Browse files
faz downgrade do django pra 1.11
1 parent 9f2db9b commit f5c048a

3 files changed

Lines changed: 73 additions & 46 deletions

File tree

config/settings.py

Lines changed: 71 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,10 @@
1-
"""
2-
Django settings for gettingstarted project.
3-
4-
Generated by 'django-admin startproject' using Django 2.0.
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-
"""
121

132
import os
3+
import dj_database_url
144
import django_heroku
155

16-
176
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
18-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
19-
20-
21-
# Quick-start development settings - unsuitable for production
22-
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
23-
24-
# SECURITY WARNING: keep the secret key used in production secret!
25-
SECRET_KEY = 'CHANGE_ME!!!! (P.S. the SECRET_KEY environment variable will be used, if set, instead).'
26-
27-
# SECURITY WARNING: don't run with debug turned on in production!
28-
DEBUG = True
29-
30-
ALLOWED_HOSTS = []
7+
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
318

329

3310
# Application definition
@@ -38,12 +15,14 @@
3815
'django.contrib.contenttypes',
3916
'django.contrib.sessions',
4017
'django.contrib.messages',
18+
'whitenoise.runserver_nostatic',
4119
'django.contrib.staticfiles',
42-
'core'
20+
'core',
4321
]
4422

4523
MIDDLEWARE = [
4624
'django.middleware.security.SecurityMiddleware',
25+
'whitenoise.middleware.WhiteNoiseMiddleware',
4726
'django.contrib.sessions.middleware.SessionMiddleware',
4827
'django.middleware.common.CommonMiddleware',
4928
'django.middleware.csrf.CsrfViewMiddleware',
@@ -52,8 +31,6 @@
5231
'django.middleware.clickjacking.XFrameOptionsMiddleware',
5332
]
5433

55-
ROOT_URLCONF = 'config.urls'
56-
5734
TEMPLATES = [
5835
{
5936
'BACKEND': 'django.template.backends.django.DjangoTemplates',
@@ -70,22 +47,24 @@
7047
},
7148
]
7249

73-
WSGI_APPLICATION = 'config.wsgi.application'
74-
75-
7650
# Database
77-
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
51+
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
7852

7953
DATABASES = {
8054
'default': {
8155
'ENGINE': 'django.db.backends.sqlite3',
8256
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
8357
}
58+
8459
}
8560

61+
# for dj_database_url
62+
db_from_env = dj_database_url.config()
63+
DATABASES['default'].update(db_from_env)
64+
8665

8766
# Password validation
88-
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
67+
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
8968

9069
AUTH_PASSWORD_VALIDATORS = [
9170
{
@@ -103,6 +82,65 @@
10382
]
10483

10584

85+
# Static files (CSS, JavaScript, Images)
86+
# https://docs.djangoproject.com/en/1.11/howto/static-files/
87+
88+
STATIC_URL = '/static/'
89+
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
90+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
91+
92+
# SECURITY WARNING: keep the secret key used in production secret!
93+
SECRET_KEY = 'CHANGE_ME!!!! (P.S. the SECRET_KEY environment variable will be used, if set, instead).'
94+
95+
# SECURITY WARNING: don't run with debug turned on in production!
96+
DEBUG = True
97+
98+
ALLOWED_HOSTS = []
99+
100+
101+
# Application definition
102+
103+
INSTALLED_APPS = [
104+
'django.contrib.admin',
105+
'django.contrib.auth',
106+
'django.contrib.contenttypes',
107+
'django.contrib.sessions',
108+
'django.contrib.messages',
109+
'django.contrib.staticfiles',
110+
'core'
111+
]
112+
113+
MIDDLEWARE = [
114+
'django.middleware.security.SecurityMiddleware',
115+
'django.contrib.sessions.middleware.SessionMiddleware',
116+
'django.middleware.common.CommonMiddleware',
117+
'django.middleware.csrf.CsrfViewMiddleware',
118+
'django.contrib.auth.middleware.AuthenticationMiddleware',
119+
'django.contrib.messages.middleware.MessageMiddleware',
120+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
121+
]
122+
123+
ROOT_URLCONF = 'config.urls'
124+
125+
TEMPLATES = [
126+
{
127+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
128+
'DIRS': [],
129+
'APP_DIRS': True,
130+
'OPTIONS': {
131+
'context_processors': [
132+
'django.template.context_processors.debug',
133+
'django.template.context_processors.request',
134+
'django.contrib.auth.context_processors.auth',
135+
'django.contrib.messages.context_processors.messages',
136+
],
137+
},
138+
},
139+
]
140+
141+
WSGI_APPLICATION = 'config.wsgi.application'
142+
143+
106144
# Internationalization
107145
# https://docs.djangoproject.com/en/2.0/topics/i18n/
108146

@@ -116,10 +154,4 @@
116154

117155
USE_TZ = True
118156

119-
120-
# Static files (CSS, JavaScript, Images)
121-
# https://docs.djangoproject.com/en/2.0/howto/static-files/
122-
123-
STATIC_URL = '/static/'
124-
125157
django_heroku.settings(locals())

config/urls.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
from django.conf.urls import include, url
2-
from django.urls import path
3-
42
from django.contrib import admin
53

6-
admin.autodiscover()
7-
8-
94
# Examples:
105
# url(r'^$', 'gettingstarted.views.home', name='home'),
116
# url(r'^blog/', include('blog.urls')),
127

138
urlpatterns = [
149
url(r'^', include('core.urls')),
15-
path('admin/', admin.site.urls),
10+
url(r'^admin/', admin.site.urls),
1611
]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
decorator==4.1.2
22
dj-database-url==0.4.2
3-
Django==2.0.1
3+
Django==1.11.8
44
django-heroku==0.2.0
55
flake8==3.5.0
66
gunicorn==19.7.1

0 commit comments

Comments
 (0)