我正在按照 Django 教程来学习如何使用它,但我很早就遇到了一个错误,并且我不知道如何修复它。
它发生在创建 django 项目并执行“编写您的第一个视图”部分时:https://docs.djangoproject.com/en/dev/intro/tutorial01/#write-your-first-view
仔细按照这些步骤操作后,执行时python3 manage.py runserver出现以下错误:AttributeError: 'str' object has no attribute 'tag'
这是完整的错误跟踪:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/home/noctis/.local/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/noctis/.local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
self.check(display_num_errors=True)
File "/home/noctis/.local/lib/python3.9/site-packages/django/core/management/base.py", line 438, in check
all_issues = checks.run_checks(
File "/home/noctis/.local/lib/python3.9/site-packages/django/core/checks/registry.py", line 77, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/home/noctis/.local/lib/python3.9/site-packages/django/core/checks/urls.py", …Run Code Online (Sandbox Code Playgroud)