我在运行Django教程时遇到问题。 我是命令行的新手,但我真的在搜索我的问题并在发布之前尝试了所有内容。
我已经尝试过使用pool应用程序的教程,我之前运行'runserver'并且它在开始时工作(Django默认页面)。当我添加urls.py时(就像在教程中一样)它已经不再使用了。 我已经发现问题是不同版本的Python(2.7,3.1,3.5),所以我卸载所有这些并只安装Python 3.5。
许可方面存在一些小问题,但我作为管理员运行终端,似乎没问题。但现在我不能再做“runserver”了。 当我输入:
C:\Users\urszulka\PycharmProjects\DJ\mysite>python manage.py runserver
我有:
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x039A5858>
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\management\base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Files (x86)\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 658, in exec_module
File "<frozen importlib._bootstrap_external>", line 764, in get_code
File "<frozen importlib._bootstrap_external>", line 724, in source_to_code
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\urszulka\PycharmProjects\DJ\mysite\mysite\urls.py", line 1
pythjo`"""mysite URL Configuration
^
SyntaxError: invalid syntax
为什么语法错误?我像以前一样做了一切。 我对你的帮助非常满意。
答案 0 :(得分:0)
文件DJ\mysite\mysite\urls.py
中存在拼写错误。看起来第1行是乱码的,因为你输入了像pythjo
这样的随机内容,而且它们不是有效的python语法。