-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

の URL がありませんhome/

あなたが追加した場合、url(r'^home/$', 'home_view', name='vista_principal'),それは行くべきものがあるでしょう。

于 2013-10-03T21:42:08.263 に答える