我在Ubuntu的virtualenv中用Django 2.0.7在python 3.6.7中做一个简单的待办事项清单,当我用样式(static / css / styles.css),我更改了settings.py并添加了以下内容:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
更多之后,我在base.html中创建了一个到样式的链接:
<link rel="stylesheet" href="{% static 'css/styles.css' %}" />
这是我的控制台输出:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f4061a4bd90>
Traceback (most recent call last):
File "/home/mario/Dev/ToDo/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/mario/Dev/ToDo/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check(display_num_errors=True)
File "/home/mario/Dev/ToDo/lib/python3.6/site-packages/django/core/management/base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "/home/mario/Dev/ToDo/lib/python3.6/site-packages/django/core/management/base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "/home/mario/Dev/ToDo/lib/python3.6/site-packages/django/core/checks/registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/mario/Dev/ToDo/lib/python3.6/site-packages/django/core/checks/urls.py", line 101, in check_url_settings
if value and not value.endswith('/'):
AttributeError: 'tuple' object has no attribute 'endswith'
答案 0 :(得分:0)
在您的settings.py
中,检查STATIC_URL
或MEDIA_URL
设置后是否有逗号结尾。看来您的代码将它们误认为一个元组。