0

我已经制作了一个“应用程序”,它应该是我的项目的首页,但是当我尝试将它用作我的项目的根目录时,http://127.0.0.1:8000/它给了我一个 404。但是,当我把它作为一个子文件夹http://127.0.0.1:8000/frontpage/时它可以工作。这是我的 urls.py 文件:

项目/urls.py

from django.conf.urls import patterns, include, url

from django.contrib import admin admin.autodiscover()

urlpatterns = patterns('',
    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    url(r'^/', include('frontpage.urls')),
    url(r'^s/', include('django.contrib.flatpages.urls')),
    url(r'^kalender/', include('events.urls')),
    #url(r'^kontakt/',    include('envelope.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^adminfiles/', include('adminfiles.urls')), )

首页/urls.py

from django.conf.urls import patterns, url

from frontpage import views

urlpatterns = patterns('',
    url(r'^$', views.index, name='index'),
)
4

1 回答 1

5
url(r'^', include('frontpage.urls', namespace="frontpage")),


urlpatterns = patterns('frontpage.views',
    url(r'^$', 'index', name='index'),
)
于 2013-03-06T08:44:25.263 回答