“module”对象没有属性“main\u page”

2024-10-01 22:33:24 发布

您现在位置:Python中文网/ 问答频道 /正文

运行命令./manage.py runserver后,我得到以下错误。我知道这肯定和网址.py(r'^$',views.main_page),但似乎不知道什么需要改变。。。有什么建议吗?在

网址.py

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

admin.autodiscover()

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'crosstalk.views.home', name='home'),
# url(r'^crosstalk/', include('crosstalk.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:
(r'^$',views.main_page),
(r'^admin/', include(admin.site.urls)),
(r'^js/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'templates/js'}),
(r"^(\d+)/$", "post"),
)

模型.py

^{pr2}$

Tags: thedjangofrompyimporturlincludeadmin
2条回答

{{{cd2>你已经登记了。更好的方法是用引号

(r'^$','content.views.main_page')

假设content是你的应用程序名。在

{{cd2>你已经定义了。这样做,包括适当的处理,它应该是有效的。在

应该是这样的:

def main_page(request):
    # view stuff goes here
    return something

相关问题 更多 >

    热门问题