Django Blog(Post)没有定义

时间:2017-11-04 14:31:51

标签: python django-views django-urls

我使用的是Django版本1.11.3,python语言版本= 3.6.3。 我试图在[PitonBlog]项目urls.py中添加[Post App] URL的路径。我在虚拟环境命令行中收到错误。 我不确定为什么系统找不到它,有什么想法?

PitonBlog是我的项目urls.py PitonBlog urls.py code

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^posts/', include("Post.urls"))
]

post-urls.py Post-urls.py code

url(r'^$', Post.views.post_home)

命令行错误

 urlconf_module = import_module(urlconf_module)
  File "C:\Users\wgori\Anaconda3\envs\Django_blogEnv\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:\Users\wgori\Desktop\myDjangoProjects\PitonBlog\Post\urls.py", line 4, in <module>
    url(r'^$', Post.views.post_home)
NameError: name 'Post' is not defined

0 个答案:

没有答案