Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

I keep getting Error while trying to deploy my django app to heroku:[ remote rejected] master -> master (pre-receive hook declined)

Below is the build log.

Git Repo: https://github.com/omolojakazeem/prosoftmaker.git
Python app detected
 !     Python has released a security update! Please consider upgrading to python-3.8.2
       Learn More: https://devcenter.heroku.com/articles/python-runtimes
cp: cannot create regular file '/app/tmp/cache/.heroku/requirements.txt': No such file or directory
-----> Installing python-3.8.1
-----> Installing pip
-----> Installing SQLite3
Sqlite3 successfully installed.
-----> Installing requirements with pip
       Collecting asgiref==3.2.7
         Downloading asgiref-3.2.7-py2.py3-none-any.whl (19 kB)
       Collecting certifi==2020.4.5.1
         Downloading certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB)
       Collecting dj-database-url==0.5.0
         Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB)
       Collecting Django==3.0.5
         Downloading Django-3.0.5-py3-none-any.whl (7.5 MB)
       Collecting django-crispy-forms==1.9.0
         Downloading django_crispy_forms-1.9.0-py2.py3-none-any.whl (107 kB)
       Collecting django-phone-field==1.8.0
         Downloading django_phone_field-1.8.0-py3-none-any.whl (7.4 kB)
       Collecting django-taggit==1.2.0
         Downloading django_taggit-1.2.0-py3-none-any.whl (45 kB)
       Collecting gunicorn==20.0.4
         Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
       Collecting Pillow==7.1.1
         Downloading Pillow-7.1.1-cp38-cp38-manylinux1_x86_64.whl (2.1 MB)
       Collecting psycopg2==2.8.5
         Downloading psycopg2-2.8.5.tar.gz (380 kB)
       Collecting pytz==2019.3
         Downloading pytz-2019.3-py2.py3-none-any.whl (509 kB)
       Collecting sqlparse==0.3.1
         Downloading sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
       Collecting whitenoise==5.0.1
         Downloading whitenoise-5.0.1-py2.py3-none-any.whl (20 kB)
       Collecting wincertstore==0.2
         Downloading wincertstore-0.2-py2.py3-none-any.whl (8.8 kB)
       Building wheels for collected packages: psycopg2
         Building wheel for psycopg2 (setup.py): started
         Building wheel for psycopg2 (setup.py): finished with status 'done'
         Created wheel for psycopg2: filename=psycopg2-2.8.5-cp38-cp38-linux_x86_64.whl size=483304 sha256=bdfbf0467dc64bcd7dc084244fa49a1acb6058ac992b962770b9c470ece03bd6
         Stored in directory: /tmp/pip-ephem-wheel-cache-my833lsg/wheels/35/64/21/9c9e2c1bb9cd6bca3c1b97b955615e37fd309f8e8b0b9fdf1a
       Successfully built psycopg2
       Installing collected packages: asgiref, certifi, dj-database-url, sqlparse, pytz, Django, django-crispy-forms, django-phone-field, django-taggit, gunicorn, Pillow, psycopg2, whitenoise, wincertstore
       Successfully installed Django-3.0.5 Pillow-7.1.1 asgiref-3.2.7 certifi-2020.4.5.1 dj-database-url-0.5.0 django-crispy-forms-1.9.0 django-phone-field-1.8.0 django-taggit-1.2.0 gunicorn-20.0.4 psycopg2-2.8.5 pytz-2019.3 sqlparse-0.3.1 whitenoise-5.0.1 wincertstore-0.2
-----> $ python manage.py collectstatic --noinput
       Traceback (most recent call last):
         File "manage.py", line 21, in <module>
           main()
         File "manage.py", line 17, in main
           execute_from_command_line(sys.argv)
         File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
           utility.execute()
         File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
           self.fetch_command(subcommand).run_from_argv(self.argv)
         File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv
           self.execute(*args, **cmd_options)
         File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute
           output = self.handle(*args, **options)
         File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
           collected = self.collect()
         File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 113, in collect
           handler(path, prefixed_path, storage)
         File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 338, in copy_file
           if not self.delete_file(path, prefixed_path, source_storage):
         File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 248, in delete_file
           if self.storage.exists(prefixed_path):
         File "/app/.heroku/python/lib/python3.8/site-packages/django/core/files/storage.py", line 311, in exists
           return os.path.exists(self.path(name))
         File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/staticfiles/storage.py", line 43, in path
           raise ImproperlyConfigured("You're using the staticfiles app "
       django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
 !     Error while running '$ python manage.py collectstatic --noinput'.
       See traceback above for details.
       You may need to update application code to resolve this error.
       Or, you can disable collectstatic for this application:
          $ heroku config:set DISABLE_COLLECTSTATIC=1
       https://devcenter.heroku.com/articles/django-assets
 !     Push rejected, failed to compile Python app.
 !     Push failed
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think you need:

settings.py

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

and then create a directory "staticfiles" in your project root directory. You have to put some file inside to upload it to git (you can't upload empty dirs to git).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...