0

Djangoチュートリアルのパート1を実行しましたが、現在はパート2に進んでおり、管理インターフェイスを起動して実行することになっています。

手順を慎重に実行しましたが、サイトを読み込もうとすると、次のエラーが発生します。

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
1. ^admin/
The current URL, , didn't match any of these.

私は最初にsettings.pyの「django.contrib.admin」のコメントを外しました

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'polls',
)

...その後、python manage.py syncdbを実行します。これにより、次の出力が得られます。

Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

...そして、urls.pyで、チュートリアルに従って想定されていた3行のコメントを解除しました。

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

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'mysite.views.home', name='home'),
    # url(r'^mysite/', include('mysite.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:
    url(r'^admin/', include(admin.site.urls)),
)

上記のように、これを実行するとエラーメッセージが生成されます。

何が間違っている可能性がありますか?つまり、想定どおりにチュートリアルに従ったということです。

4

1 に答える 1

2

チュートリアルの指示に注意してください。

ここで、Web ブラウザを開き、ローカル ドメインの「/admin/」に移動しますhttp://127.0.0.1:8000/admin/

エラー ショーを追加します。ルート URL にアクセスしようとしていますが、/admin/指示どおりではありません。

于 2013-02-24T16:30:25.123 に答える