我不知道出了什么问题,因为这个错误我两天都没有睡觉。我不知道它来自哪里,它不会让我知道我做错了什么。为了你的信息,我正在学习使用django和python,我的django版本是1.11,我的python版本是2.7。请帮助我,这是我从我的代码中得到的
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/management/commands/check.py", line 68, in handle
fail_level=getattr(checks, options['fail_level']),
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/management/base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/management/base.py", line 361, in _run_checks
return checks.run_checks(**kwargs)
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 28, in check_resolver
warnings.extend(check_resolver(pattern))
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 30, in check_resolver
warnings.extend(check_pattern_name(pattern))
File "/home/juunnn/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 120, in check_pattern_name
if pattern.name is not None and ":" in pattern.name:
TypeError: argument of type 'function' is not iterable
请参阅?它不会让我知道我的错在哪里。
答案 0 :(得分:1)
错误表明您在命名网址格式时忘记了引号。
例如,您有name=my_view
,
url('^my-url/$', my_view, name=my_view)
何时应使用字符串name='my_view'
:
url('^my-url/$', my_view, name='my_view')