【发布时间】:2014-11-26 21:57:37
【问题描述】:
我正在 heroku 上运行一个 django 项目。在看到我的 favicon.ico 无法加载后,我决定在访问我的页面 example.com/favicon.ico 时查看它是否正常工作。
我(在多个浏览器上)看到的是这样的死图像:https://app.box.com/s/q9uqb2kmooak93ockvbl
我正在为 favicon.ico 提供服务:
<link rel="shortcut icon" href="{% static 'favicon.ico' %}" type="image/x-icon"/>
另外,我应该提到我正在重定向我的 django 项目中的 url,如下所示:
#serving favicon
(r'^favicon\.ico$', RedirectView.as_view(url='/static/favicon.ico')),
不过这应该没关系。
我想知道这是不是一个问题:
- 我正在尝试渲染的图像(虽然我对此表示怀疑,因为其他图像渲染得很好)
- heroku 的问题
- 还是快捷方式图标参考链接有问题?
以下是我的静态设置:
STATIC_URL = '/static/'
# only refers to the location where your static files should end up after running manage.py collectstatic. you shouldn't really need collectstatic) when developing locally
STATIC_ROOT = 'staticfiles'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, '../static'),
)
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(BASE_DIR, '../templates'),
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
有什么想法吗?
【问题讨论】:
-
你可以在虚拟主机中添加别名参考[this][1]问题[1]:stackoverflow.com/questions/21938028/…
标签: python django heroku django-urls favicon