[英]collectstatic not reading settings file using git push heroku master but reads it when run on its own
If I enter 如果我输入
>>> git push heroku master
I get an error. 我得到一个错误。 Notice line 25 stating that I have not set the STATIC_ROOT
setting. 注意,第25行指出我尚未设置STATIC_ROOT
设置。
1 remote: -----> $ python manage.py collectstatic --noinput
2 remote: Traceback (most recent call last):
3 remote: File "manage.py", line 22, in
4 remote: execute_from_command_line(sys.argv)
5 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
6 remote: utility.execute()
7 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 355, in execute
8 remote: self.fetch_command(subcommand).run_from_argv(self.argv)
9 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
10 remote: self.execute(*args, **cmd_options)
11 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
12 remote: output = self.handle(*args, **options)
13 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 199, in handle
14 remote: collected = self.collect()
15 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 124, in collect
16 remote: handler(path, prefixed_path, storage)
17 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 354, in copy_file
18 remote: if not self.delete_file(path, prefixed_path, source_storage)
19 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 260, in delete_file
20 remote: if self.storage.exists(prefixed_path):
21 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/core/files/storage.py", line 392, in exists
22 remote: return os.path.exists(self.path(name))
23 remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/storage.py", line 50, in path
24 remote: raise ImproperlyConfigured("You're using the staticfiles app "
25 remote: django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
26 remote:
27 remote: ! Error while running '$ python manage.py collectstatic --noinput'
28 remote: See traceback above for details.
My settings file includes these values 我的设置文件包含这些值
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
In addition, if I enter python manage.py collectstatic --noinput
it runs fine. 另外,如果我输入python manage.py collectstatic --noinput
它将运行良好。
I just checked github. 我刚刚检查了github。 It turns out my settings file was not in sync with my local settings file. 事实证明我的设置文件与本地设置文件不同步。 Meaning the settings file on github didn't have STATIC_ROOT
set. 意味着github上的设置文件未设置STATIC_ROOT
。 I just 我只是
git add -A
git commit -m "Added files and changes required for `deployment to heroku"
git push origin master
Which updated my settings file on github. 哪个更新了我在github上的设置文件。 Then 然后
heroku create
git push heroku master
It worked. 有效。 I don't know if this is helpful. 我不知道这是否有帮助。 If someone downvotes, I'll delete this question. 如果有人反对,我将删除此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.