![](/img/trans.png)
[英]Django TemplateSyntaxError - 'staticfiles' is not a registered tag library
[英]'staticfiles' is not a registered tag library: These solutions don't work
我是 Heroku 和 Django 的新手。
现在我正在使用 Python 开始使用 Heroku 。
当我访问https://(...secret...)-app-123.herokuapp.com/db
,
我收到以下错误:
'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
static
tz
然后我找到了这些解决方案。
但是,这些解决方案并不能解决我的问题。
首先,我改变了
{% load staticfiles %}
到
{% load static %}
...在db.html
。
它给了我:
run python manage.py migrate
Running python manage.py migrate on ⬢ (...secret...)-app-123... up, run.3361 (Free)
Operations to perform:
Apply all migrations: admin, auth, contenttypes, hello, sessions
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
由于错误消息告诉我运行manage.py makemigrations
,我运行:
manage.py makemigrations
Traceback (most recent call last):
File "C:\Users\xxxxx\python-getting-started\manage.py", line 8, in ?
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
没有模块?
Django 安装在我的机器上。
我不知道该怎么办,所以我在本地机器上更新了 Django:
C:\Users\xxxxx\python-getting-started>pip install django --upgrade
Requirement already up-to-date: django in c:\users\xxxxx\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (3.1.2)
Requirement already satisfied, skipping upgrade: sqlparse>=0.2.2 in c:\users\xxxxx\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from django) (0.4.1)
Requirement already satisfied, skipping upgrade: pytz in c:\users\xxxxx\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from django) (2020.1)
Requirement already satisfied, skipping upgrade: asgiref~=3.2.10 in c:\users\xxxxx\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from django) (3.2.10)
......但是,它并没有解决我的问题。
我还补充道:
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
VENV_PATH = os.path.dirname(BASE_DIR)
STATIC_ROOT = os.path.join(VENV_PATH, 'static_root')
在settings.py
的末尾,但它也不起作用。
我还可以做些什么?
对于您的信息,到目前为止,在使用 Python 开始 Heroku 上还没有任何错误。
如果您有任何错误,您甚至无法到达这里。
请随意询问我的设置,输入这个,输入那个等等。提前谢谢你。
您应该使用虚拟环境。 在虚拟环境中管理 django 项目会更容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.