在Heroku上部署Django时出现问题

在Heroku上部署Django时出现问题,django,heroku,Django,Heroku,嗨,伙计们,我尝试在heroku上部署我的第一个django,我经常遇到部署问题 我认为这与我的settings.py文件有关。 我显然不知道python manage.py collectstatic noinput这个问题,但我已经写了所有东西 提前感谢您的帮助和想法 $ python manage.py collectstatic--noinput Traceback(most recent call last): File "manage.py", line 21,

嗨,伙计们,我尝试在heroku上部署我的第一个django,我经常遇到部署问题

我认为这与我的settings.py文件有关。 我显然不知道python manage.py collectstatic noinput这个问题,但我已经写了所有东西

提前感谢您的帮助和想法

$ 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.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
           utility.execute()
         File "/app/.heroku/python/lib/python3.6/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.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
           self.execute(*args, **cmd_options)
         File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute
           output = self.handle(*args, **options)
         File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
           collected = self.collect()
         File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 104, in collect
           for path, storage in finder.list(self.ignore_patterns):
         File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/finders.py", line 130, in list
           for path in utils.get_files(storage, ignore_patterns):
         File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/utils.py", line 23, in get_files
           directories, files = storage.listdir(location)
         File "/app/.heroku/python/lib/python3.6/site-packages/django/core/files/storage.py", line 316, in listdir
           for entry in os.scandir(path):
       FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_6613795b_/static'
 !     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

您只需要在settings.py文件中保留以下一行

用这个

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
还是这个 并非都在settings.py文件中

此外,您还可以使用以下命令:

python manage.py collectstatic

谢谢你,帕布乔特。这很管用,但是出现了一个新问题。请告诉我是什么问题。
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
python manage.py collectstatic