Django - runserver错误值错误:源代码字符串不能包含空字节

时间:2017-11-06 07:51:38

标签: python django

我刚刚开始学习django,我正在网上尝试一些教程。请帮忙。这只是一个接受用户输入的小型Web应用程序,并将其显示在留言板上。

我正在使用windows和django 1.11.7。我使用sublime文本编辑器进行python。

我不确定这个错误意味着什么。如果有人可以提供帮助,那将会有很大的帮助。这是我得到的错误:

`  Unhandled exception in thread started by <function check_errors.<locals>.wrapper
     at 0x03BF8F18>
    Traceback (most recent call last):
      File "C:\dev\message_board\mb\lib\site-packages\django\utils\autoreload.py", l
    ine 228, in wrapper
        fn(*args, **kwargs)
      File "C:\dev\message_board\mb\lib\site-packages\django\core\management\command
    s\runserver.py", line 125, in inner_run
        self.check(display_num_errors=True)
      File "C:\dev\message_board\mb\lib\site-packages\django\core\management\base.py
    ", line 359, in check
        include_deployment_checks=include_deployment_checks,
      File "C:\dev\message_board\mb\lib\site-packages\django\core\management\base.py
    ", line 346, in _run_checks
        return checks.run_checks(**kwargs)
      File "C:\dev\message_board\mb\lib\site-packages\django\core\checks\registry.py
    ", line 81, in run_checks
        new_errors = check(app_configs=app_configs)
      File "C:\dev\message_board\mb\lib\site-packages\django\core\checks\urls.py", l
    ine 16, in check_url_config
        return check_resolver(resolver)
      File "C:\dev\message_board\mb\lib\site-packages\django\core\checks\urls.py", l
    ine 26, in check_resolver
        return check_method()
      File "C:\dev\message_board\mb\lib\site-packages\django\urls\resolvers.py", lin
    e 254, in check
        for pattern in self.url_patterns:
      File "C:\dev\message_board\mb\lib\site-packages\django\utils\functional.py", l
    ine 35, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "C:\dev\message_board\mb\lib\site-packages\django\urls\resolvers.py", lin
    e 405, in url_patterns
        patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
      File "C:\dev\message_board\mb\lib\site-packages\django\utils\functional.py", l
    ine 35, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "C:\dev\message_board\mb\lib\site-packages\django\urls\resolvers.py", lin
    e 398, in urlconf_module
        return import_module(self.urlconf_name)
      File "C:\dev\message_board\mb\lib\importlib\__init__.py", line 126, in import_
    module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 678, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "C:\dev\message_board\mb\mb_project\urls.py", line 7, in <module>
        url(r'^', include('message_app.urls')),
      File "C:\dev\message_board\mb\lib\site-packages\django\conf\urls\__init__.py",
     line 50, in include
        urlconf_module = import_module(urlconf_module)
      File "C:\dev\message_board\mb\lib\importlib\__init__.py", line 126, in import_
    module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 674, in exec_module
      File "<frozen importlib._bootstrap_external>", line 781, in get_code
      File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    ValueError: source code string cannot contain null bytes`

这是显示错误的文件:

`# mb_project/urls.py
from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('message_app.urls')),
]`

这是message_app / urls文件:

from django.conf.urls import url

from .views import Home_page_view

urlpatterns = [
    url(r'^$', Home_page_view.as_view()),
]

谢谢

0 个答案:

没有答案