https://docs.djangoproject.com/en/dev/intro/tutorial01/にある Django のチュートリアルに従おうとしています。
次のような独自のモデルを作成しました。
from django.db import models
class Order(models.Model):
name = models.CharField(max_length=30)
quantity = models.IntegerField()
そして私のsettings.pyは次のようになります:
ROOT_URLCONF = 'lcf.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'lcf.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
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',
'lcf',
)
urls.py は次のようになります。
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'^$', 'tsg.views.home', name='home'),
# url(r'^tsg/', include('tsg.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)),
)
でも、走った後は
python manage.py syncdb
そして実行中
python manage.py runserver
ブラウザに次のエラーが表示されます。
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.4.1
Python Version: 2.6.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'lcf')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/home/staff/nallurv/Envs/tsg/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
101. request.path_info)
File "/home/staff/nallurv/Envs/tsg/lib/python2.6/site-packages/django/core/urlresolvers.py" in resolve
298. for pattern in self.url_patterns:
File "/home/staff/nallurv/Envs/tsg/lib/python2.6/site-packages/django/core/urlresolvers.py" in url_patterns
328. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/staff/nallurv/Envs/tsg/lib/python2.6/site-packages/django/core/urlresolvers.py" in urlconf_module
323. self._urlconf_module = import_module(self.urlconf_name)
File "/home/staff/nallurv/Envs/tsg/lib/python2.6/site-packages/django/utils/importlib.py" in import_module
35. __import__(name)
Exception Type: ImportError at /
Exception Value: No module named urls