dyl*_*aur 8 python heroku syntax-error heroku-postgres
刚开始使用 Heroku,我在学习 Python 教程时已经遇到了障碍。在配置数据库之前,每一步都非常简单。 执行后,heroku run python manage.py migrate我应该能够在添加/db到 URL 末尾后看到数据库,但是我被发送到一个错误页面,如下所示:
TemplateSyntaxError at /db/
'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
static
tz
Request Method: GET
Request URL: https://morning-oasis-00207.herokuapp.com/db/
Django Version: 3.0
Exception Type: TemplateSyntaxError
Exception Value:
'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
static
tz
Exception Location: /app/.heroku/python/lib/python3.7/site-packages/django/template/defaulttags.py in find_library, line 1025
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.7.3
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python37.zip',
'/app/.heroku/python/lib/python3.7',
'/app/.heroku/python/lib/python3.7/lib-dynload',
'/app/.heroku/python/lib/python3.7/site-packages']
Server time: Wed, 11 Dec 2019 23:17:58 +0000
Run Code Online (Sandbox Code Playgroud)
我真的一个接一个地完全按照这些步骤操作,所以我在这里有点不知所措。我会跳过这个,但我需要为我将要从事的项目使用数据库,我想知道将来如何避免这种情况。我在这里查看了其他几个类似的讨论,但没有看到任何特定于本教程的内容。任何帮助,将不胜感激。
小智 12
这里也有同样的问题。似乎最近在 Django 3.0.0中更新了 staticfiles 模板标记库(其中不推荐使用 staticfiles),Heroku 可能没有更新教程文件。
转到您的本地应用程序目录(从 中创建cd python-getting-started)并找到 settings.py(python-getting-started\gettingstarted\settings.py)。滚动到底部并更改STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')为STATIC_ROOT = os.path.join(BASE_DIR, 'static')。
转到找到的模板数据库html文件python-getting-started\hello\templates\db.html并更改{% load staticfiles %}为{% load static %}
转到根文件夹并将静态文件文件夹重命名staticfiles为static
希望这可以帮助。确保更新您的更改。
| 归档时间: |
|
| 查看次数: |
306 次 |
| 最近记录: |