Entering Tutorial 2 from this time http://www.djangoproject.jp/doc/ja/1.0/intro/tutorial02.html#intro-tutorial02
By the way, in my environment, python is 2.7.5 and DJango is 1.6.
First check settings.py
settings.py ######
#this part
INSTALLED_APPS = (
     'django.contrib.admin',   #I need this. In my case it was included by default
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
     'django.contrib.sites',
     'polls'
 )
If you add it again
python manage.py syncdb
Execute. It's a theory to add a database after adding an application. Then edit urls.py. I got a little troubled here.
urls.py ###### In the tutorial
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
    # Example:
    # (r'^mysite/', include('mysite.foo.urls')),
    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    # Uncomment the next line to enable the admin:
    (r'^admin/(.*)', admin.site.root),
)
Since it is described as such, for the time being, just do it
python manage.py runserver
After this, if you go to http://127.0.0.1:8000/admin/, you should see the login screen. But the result is an error. The message is
ImportError at /admin/
No module named defaults
I think it may be due to the difference in version (the tutorial assumes 1.0, but I am 1.6), so I will return to the state before editing. Actually, there was the following description before editing.
from django.conf.urls import patterns, include, url   #Import statement included by default
 
from django.contrib import admin
admin.autodiscover()
 
urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'myDj.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^admin/', include(admin.site.urls)),   #All examples()Is preceded by a url
)
Since what I'm doing looks the same, I thought that the writing style had changed, so I started it and accessed it. But again, no. However, the error message is different.
ImproperlyConfigured at /admin/
You're using the Django "sites framework" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting to fix this error.
I don `t really understand. It's understandable that you are told to set a site ID, but how do you do that? Even if I googled with an error message
This time I tried to write in a timely manner as a measure of bitterness.
from django.conf.urls import patterns, include, url   #Adopt the one that does not fail here
from django.contrib import admin
admin.autodiscover()
 
urlpatterns = patterns('',
    #Default notation url(r'^admin/', include(admin.site.urls))
    #Tutorial notation(r'^admin/(.*)', admin.site.root)
    url(r'^admin/(.*)', include(admin.site.root))
Then
AttributeError at /admin/
'AdminSite' object has no attribute 'root'
The above is the contents at that time.
Now it's resolved thanks to the comments (I'm glad I posted it).
Recommended Posts