0

我的 django 项目中有一个非常基本的 url 路由器:

from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

from django.contrib import admin
admin.autodiscover()

urlpatterns = staticfiles_urlpatterns()

urlpatterns += patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^/?', include('customApp.urls')),
)

当我启动开发服务器并转到 时127.0.0.1:8000/admin/,出现ViewDoesNotExist at /admin/错误。

以下是异常的内容:

Could not import customApp.views.event. View does not exist in module customApp.views.

我已经尝试重新排序网址(我不知道这会有什么帮助,但我还是尝试过)并更改r'^/?'r'^/'.

当我注释掉最后一个 url 时,管理页面再次工作。

这是customApp.urls代码:

from django.conf.urls import patterns, include, url
import django.contrib.auth.views
import django.contrib.auth

urlpatterns = patterns('customApp.views',
    url(r'^$', 'index'),
    url(r'^rest/v1/event/add/$', 'event'),
    url(r'^rest/v1/reports/$', 'reports'),
)

urlpatterns += patterns('',
    url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
)
4

1 回答 1

1

这是简单的伙伴。Django cannot find customApp views. 请确保您在 urls.py 中获得的任何视图都应该存在。

谢谢

于 2012-10-06T02:47:51.413 回答