对 django 来说非常新。我使用的是 1.5.2 版本,并且刚刚进行了全新安装。我正在使用 django 开发服务器;我将在未来转向 Apache,但在迈出这一步之前,我想了解 django 独特的 MVC 方法论。
所以我通过我的项目目录(django_books)中的终端使用“python manage.py runserver 0.0.0.0:8000”启动django服务器。我收到此错误:
ViewDoesNotExist at /
Could not import django_books.views.home. Parent module django_books.views does not exist.
所以我的观点不存在。我的 view.py 文件是空的,因为我遵循的教程没有包含一个。我不确定这是否是问题所在。如果是,我如何创建这个文件(里面有什么)?
目录结构:
django_books
beer (from the tutorial lol)
migrations
__init__.py
models.py
views.py
random_book
(same as beer above)
django_books (this is my actual django project, beer and random_book are apps)
__init__.py
settings.py
urls.py
wsgi.py
media
.gitignore
manage.py
requirements.txt (output from pip freeze command)
网址.py
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^$', 'django_books.views.home', name='home'),
# url(r'^django_books/', include('django_books.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)