django - 未找到页面(404)

时间:2013-10-03 21:35:24

标签: python django

这是我的第一个django应用程序,我收到了以下消息:

找不到页面(404) 请求方法:GET 请求网址:

使用_3Ms.urls中定义的URLconf,Django按以下顺序尝试了这些URL模式:

^ ^$ [name='vista_principal']
^admin/doc/
^admin/

当前网址home /与其中任何一个都不匹配。


我的setting.py

MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media/')

MEDIA_URL = '/media/'

STATIC_ROOT = ''

STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (

)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '7th)hsx0w5mwlv+oty62w(us7&xtiw#y0&12)67ld%6y1-a)4f'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = '_3Ms.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = '_3Ms.wsgi.application'

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), 'templates'),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'apps',
)

_3Ms / urls.py

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


admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', '_3Ms.views.home', name='home'),
    # url(r'^_3Ms/', include('_3Ms.foo.urls')),
    url(r'^', include('apps.es.urls')), # incluye las urls de es.urls.py
    # 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)),
)

ES / urls.py

from django.conf.urls import patterns, url


urlpatterns = patterns('apps.es.view',
        url(r'^$', 'home_view', name='vista_principal'),
)

ES / views.py

from django.shortcuts import render_to_response
from django.template import RequestContext


def home_view(request):
    return render_to_response('es/home.html', context_instance=RequestContext(request))

1 个答案:

答案 0 :(得分:0)

您没有home/的网址。

如果你添加了url(r'^home/$', 'home_view', name='vista_principal'),,那么就可以了。