Quellcode durchsuchen

- configuraciones para Heroku

Hugo Camargo vor 4 Jahren
Ursprung
Commit
fc16ed55c0
5 geänderte Dateien mit 27 neuen und 2 gelöschten Zeilen
  1. 1 0
      .gitignore
  2. 1 0
      cloud/Procfile
  3. 17 2
      cloud/cloud/settings.py
  4. 1 0
      cloud/runtime.txt
  5. 7 0
      requirements.txt

+ 1 - 0
.gitignore

@@ -19,3 +19,4 @@ env/
 .DS_Store
 media/
 static/
+

+ 1 - 0
cloud/Procfile

@@ -0,0 +1 @@
+web: gunicorn PROJECT_NAME.wsgi

+ 17 - 2
cloud/cloud/settings.py

@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
 
 import os
 
+import dj_database_url
+
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 
@@ -23,7 +25,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 SECRET_KEY = '%nu-#)p4b$z(983hj_##91%_^x=3n#*as874q8b439=q@4g0bx'
 
 # SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
+DEBUG = False
 
 ALLOWED_HOSTS = []
 
@@ -37,10 +39,16 @@ INSTALLED_APPS = [
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
+
+    'whitenoise.runserver_nostatic'
 ]
 
 MIDDLEWARE = [
     'django.middleware.security.SecurityMiddleware',
+
+    # Add whitenoise middleware here
+    'whitenoise.middleware.WhiteNoiseMiddleware',
+
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.common.CommonMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
@@ -79,7 +87,8 @@ DATABASES = {
         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
     }
 }
-
+db_from_env = dj_database_url.config(conn_max_age=500)
+DATABASES['default'].update(db_from_env)
 
 # Password validation
 # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
@@ -118,3 +127,9 @@ USE_TZ = True
 # https://docs.djangoproject.com/en/2.2/howto/static-files/
 
 STATIC_URL = '/static/'
+
+STATIC_ROOT = os.path.join(BASE_DIR, 'static')
+
+ALLOWED_HOSTS = ['127.0.0.1', '.herokuapp.com']
+
+STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

+ 1 - 0
cloud/runtime.txt

@@ -0,0 +1 @@
+python-3.6.8

+ 7 - 0
requirements.txt

@@ -0,0 +1,7 @@
+dj-database-url==0.5.0
+Django==2.2
+gunicorn==20.1.0
+psycopg2-binary==2.9.2
+pytz==2021.3
+sqlparse==0.4.2
+whitenoise==5.3.0