deploy to Heroku " collectstatic --noinput "

369 views
Skip to first unread message

omar ahmed

unread,
May 26, 2019, 5:34:54 PM5/26/19
to Django users
git push heroku master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 414 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing requirements with pip
remote:
remote: -----> $ python manage.py collectstatic --noinput
remote:        122 static files copied to '/tmp/build_ae5c33e3156cddd5969268ac72b87668/staticfiles', 392 post-processed.
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 55.3M
remote: -----> Launching...
remote:        Released v12
remote:        https://arena3.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/arena3.git
   48d580d..0dcd3ad  master -> master

settings.py

"""
Django settings for arena project.

Generated by 'django-admin startproject' using Django 2.2.1.

For more information on this file, see

For the full list of settings and their values, see
"""

import os
import django_heroku
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__)))


# Quick-start development settings - unsuitable for production

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '=l&e$6@=a%bu(--=pgd)-i!(&eeag%-ik&%7k11l_7*3j11eln'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'core.apps.CoreConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_social_share',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'arena.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'core.context_processors.add_to_base',
],
},
},
]

WSGI_APPLICATION = 'arena.wsgi.application'


# Database

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'arenadb',
     'USER': 'arenaomar',
     'PASSWORD': '',
     'HOST': 'localhost',
     'PORT': '',
}
}


# Password validation

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)


PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
LOGIN_REDIRECT_URL = 'core:home'
LOGOUT_REDIRECT_URL = 'core:home'
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
django_heroku.settings(locals())

Joe Reitman

unread,
May 27, 2019, 11:10:06 AM5/27/19
to Django users
Is there a question here? I will point out what I see wrong in Settings.py.

Allowed_hosts is empty. Need the host domain.
Missing Port number for your database
Did you migrate your models?
Secret key should be stored in environment variable

salimon jamiu olashile

unread,
May 27, 2019, 2:45:59 PM5/27/19
to django...@googlegroups.com
Hello Omar, what’s the problem?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5edbcc2c-ce02-4949-906e-e75b4f519016%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

omar ahmed

unread,
May 27, 2019, 3:46:32 PM5/27/19
to Django users
i can't publish my project
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.
screen.png

Andrew C.

unread,
May 27, 2019, 3:51:06 PM5/27/19
to django...@googlegroups.com
Follow a tutorial. 
1) Hide your secret key and everything secretive in an environment variable. Or use Django-environ
2) Try python manage.py check —deploy
3) Debug is set to True... it should not be True if you’re publishing (deploying)

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Stephen L

unread,
May 27, 2019, 4:07:10 PM5/27/19
to django...@googlegroups.com
This is a migration problem



always run migrations before committing to heroku, but you can also run it on heroku: 

heroku run python manage.py makemigrations
heroku run python manage.py migrate

 

Reply all
Reply to author
Forward
0 new messages