Python 配置不当的静态文件

Python 配置不当的静态文件,python,django,heroku,django-staticfiles,Python,Django,Heroku,Django Staticfiles,我在Heroku上部署了一个简单的博客应用程序,它运行于Django=1.8.4,我在静态文件方面遇到了一些问题 当打开我的应用程序时,我看到应用程序错误页面,所以我尝试调试它,发现当我提交给Heroku时,它无法在我的静态文件夹上执行collectstatic。其他一切都在运行,Heroku向我展示了构建成功了,但无法执行 remote: -----> Preparing static assets remote: Collectstatic configuration e

我在Heroku上部署了一个简单的博客应用程序,它运行于
Django=1.8.4
,我在静态文件方面遇到了一些问题

当打开我的应用程序时,我看到
应用程序错误
页面,所以我尝试调试它,发现当我提交给Heroku时,它无法在我的静态文件夹上执行collectstatic。其他一切都在运行,Heroku向我展示了
构建成功了
,但无法执行

remote: -----> Preparing static assets
remote:        Collectstatic configuration error. To debug, run:
remote:        $ heroku run python bloggy_project/manage.py collectstatic --noinput
所以Heroku想让我调试它。我打字之后

heroku run python bloggy_project/manage.py collectstatic --noinput
错误日志显示:

Running python bloggy_project/manage.py collectstatic --noinput on greenbloggy... up, run.4682
Traceback (most recent call last):
  File "bloggy_project/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 190, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 41, in load_command_class
    return module.Command()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 32, in __init__
    self.storage.path('')
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 48, 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.
更新:

当我注释掉
STATIC\u ROOT
,并执行

heroku run python bloggy_project/manage.py collectstatic --noinput
错误日志现在显示了,这部分很混乱,如果我需要在我的
settings.py
中放入
STATIC\u ROOT
,为什么现在会出现此错误

新的错误日志:

Traceback (most recent call last):
  File "bloggy_project/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle
    collected = self.collect()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 97, in collect
    for finder in get_finders():
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 264, in get_finders
    yield get_finder(finder_path)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper
    result = user_function(*args, **kwds)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 277, in get_finder
    return Finder()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 66, in __init__
    "The STATICFILES_DIRS setting should "
django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting
回溯(最近一次呼叫最后一次):
文件“bloggy_project/manage.py”,第10行,在
从命令行(sys.argv)执行命令
文件“/app/.heroku/python/lib/python2.7/site packages/django/core/management/\uu init\uu.py”,第338行,从命令行执行
utility.execute()
文件“/app/.heroku/python/lib/python2.7/site packages/django/core/management/_init__.py”,执行中第330行
self.fetch_命令(子命令)。从_argv(self.argv)运行_
文件“/app/.heroku/python/lib/python2.7/site packages/django/core/management/base.py”,第393行,在运行时从
self.execute(*args,**cmd_选项)
文件“/app/.heroku/python/lib/python2.7/site packages/django/core/management/base.py”,执行中第444行
输出=self.handle(*args,**选项)
文件“/app/.heroku/python/lib/python2.7/site packages/django/contrib/staticfiles/management/commands/collectstatic.py”,第168行,在handle中
collected=self.collect()
文件“/app/.heroku/python/lib/python2.7/site packages/django/contrib/staticfiles/management/commands/collectstatic.py”,第97行,在collect中
对于get_finders()中的finder:
get_finders中的文件“/app/.heroku/python/lib/python2.7/site packages/django/contrib/staticfiles/finders.py”,第264行
收益获取查找器(查找器路径)
包装器中的文件“/app/.heroku/python/lib/python2.7/site packages/django/utils/lru_cache.py”,第101行
结果=用户函数(*args,**kwds)
get_finder中的文件“/app/.heroku/python/lib/python2.7/site packages/django/contrib/staticfiles/finders.py”,第277行
返回查找器()
文件“/app/.heroku/python/lib/python2.7/site packages/django/contrib/staticfiles/finders.py”,第66行,在__
“STATICFILES\u DIRS设置应”
django.core.exceptions.impropertlyconfigured:STATICFILES\u DIRS设置不应包含STATIC\u ROOT设置

出现此错误是因为设置变量
STATIC\u ROOT
STATICFILES\u DIRS
包含完全相同的路径(
os.path.join(BASE\u DIR,'STATIC')
)。这是一个无效的配置

STATIC\u ROOT
是您希望Django将使用
collectstatic
收集的静态文件放置到的绝对路径。您的web服务器将提供此目录中的静态文件

STATICFILES\u DIRS
是收集静态文件时希望
collectstatic
查看的目录列表。如果不能包括
静态\u根
或其任何子目录


尝试删除
STATICFILES\u DIRS
设置,看看是否有效。如果您已将静态文件放在某些非标准位置,请更改设置以包括该位置。

可能您尚未在Django setting.py中提供静态根路径,因此请再次检查,如果未提供,请提供路径。给出您选择的路径,然后运行它将运行的命令。

错误说明了问题所在:您没有设置STATIC\u ROOT。出于某种原因,您已经注释掉了settings.py中设置它的行。@DanielRoseman,我已经更新了我的问题,这样做了,注释掉了
STATIC\u ROOT
,但是现在它显示了另一个错误,这部分让我很困惑,为什么现在会出现这个错误?STATIC folder是我的项目根目录,manage.py在这里。在这里检查[repository](),不是在家atm,但我将尝试按照您的建议进行操作,并提供有关结果的信息。我已解决了一个静态文件问题,需要在本地执行
/manage collectstatic
,谢谢。
Traceback (most recent call last):
  File "bloggy_project/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle
    collected = self.collect()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 97, in collect
    for finder in get_finders():
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 264, in get_finders
    yield get_finder(finder_path)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper
    result = user_function(*args, **kwds)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 277, in get_finder
    return Finder()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 66, in __init__
    "The STATICFILES_DIRS setting should "
django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting