-1

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

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

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

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

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


我的设置.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))
4

1 回答 1

0

您没有home/.

如果你添加url(r'^home/$', 'home_view', name='vista_principal'),它会有一些东西去。

于 2013-10-03T21:42:08.263 回答