0

I followed a tutorial to have a production and local environment for my django app. But when I pushed it to heroku it was rejected. it worked fine locally though. I created a folder called settings and made it a module by putting __init__.py insde of it. I changed the name of my original settings.py and named it Old_settings .py. I then created a file called base.py with all my original settings.py code. Then inside of the init file I did this

from .base import *

try:
    from .local import *
except:
    pass

try:
    from .production import *
except:
    pass

in the the production

import os
import dj_database_url

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
SECRET_KEY = os.environ['SECRET_KEY']
DEBUG = False

in the local

import os
import dj_database_url

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
SECRET_KEY = '------------------------------------------'
DEBUG = True

I also changed this

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

to this

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))

but when i push it to heroku master it's rejeced. What am I missing

EDIT my Complete error message

        Counting objects: 18, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (17/17), done.
    Writing objects: 100% (18/18), 3.10 KiB | 0 bytes/s, done.
    Total 18 (delta 11), reused 0 (delta 0)
    remote: Compressing source files... done.
    remote: Building source:
    remote: 
    remote: -----> Using set buildpack heroku/python
    remote: -----> Python app detected
    remote:      $ pip install -r requirements.txt
    remote: 
    remote:      $ python manage.py collectstatic --noinput
    remote:        Traceback (most recent call last):
    remote:          File "manage.py", line 10, in <module>
    remote:            execute_from_command_line(sys.argv)
    remote:          File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    remote:            utility.execute()
    remote:          File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in execute
    remote:            self.fetch_command(subcommand).run_from_argv(self.argv)
    remote:          File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv
    remote:            self.execute(*args, **cmd_options)
    remote:          File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 399, in execute
    remote:            output = self.handle(*args, **options)
    remote:          File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 176, in handle
    remote:            collected = self.collect()
    remote:          File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
    remote:            for path, storage in finder.list(self.ignore_patterns):
    remote:          File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/finders.py", line 112, in list
    remote:            for path in utils.get_files(storage, ignore_patterns):
    remote:          File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
    remote:            directories, files = storage.listdir(location)
    remote:          File "/app/.heroku/python/lib/python3.5/site-packages/django/core/files/storage.py", line 299, in listdir
    remote:            for entry in os.listdir(path):
    remote:        FileNotFoundError: [Errno 2] No such file or directory: '/app/gettingstarted/settings/static'
    remote: 
    remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
    remote:        See traceback above for details.
    remote: 
    remote:        You may need to update application code to resolve this error.
    remote:        Or, you can disable collectstatic for this application:
    remote: 
    remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
    remote: 
    remote:        https://devcenter.heroku.com/articles/django-assets
    remote: 
    remote:  !     Push rejected, failed to compile Python app
    remote: 
    remote: Verifying deploy...
    remote: 
    remote: !       Push rejected to examplesite.

remote: 
To https://git.heroku.com/examplesite.git
 ! [remote rejected] master -> master (pre-receive hook declined)

my old path was

 src/gettingstarted/settings.py 

but now it's

src/gettingstarted/settings/
                        __init__.py
                        base.py
                        local.py
                        production.py

I think it's a directory issue But I'm a bit confused as to how to do correct it

nothingness
  • 971
  • 3
  • 10
  • 18

0 Answers0