私はpythonとdjangoをセットアップし、単純なアプリ「mysite」を構築しようとしていました
urls.py が root/mysite/ にあるときに、ルート フォルダーに views.py を作成しました。 /hello を呼び出すと、次のエラーが表示されます。修正するにはどうすればよいですか?
NameError at /hello
name 'hello' is not defined
Request Method: GET
Request URL: ~~:8000/hello
Django Version: 1.5
Exception Type: NameError
Exception Value:
name 'hello' is not defined
Exception Location: c:\Python27\Django-1.5\mysite\mysite\urls.py in <module>, line 17
Python Executable: c:\Python27\python.exe
Python Version: 2.7.2
Python Path:
['c:\\Python27\\Django-1.5\\mysite',
'c:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
'c:\\Python27\\lib\\site-packages\\pymysql-0.3-py2.7.egg',
'C:\\Windows\\system32\\python27.zip',
'c:\\Python27\\DLLs',
'c:\\Python27\\lib',
'c:\\Python27\\lib\\plat-win',
'c:\\Python27\\lib\\lib-tk',
'c:\\Python27',
'c:\\Python27\\lib\\site-packages']
Server time: Tue, 26 Mar 2013 18:40:41 +0530
Traceback Switch to copy-and-paste view
c:\Python27\lib\site-packages\django\core\handlers\base.py in get_response
response = middleware_method(request)
...
▶ Local vars
c:\Python27\lib\site-packages\django\middleware\common.py in process_request
if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
...
▶ Local vars
c:\Python27\lib\site-packages\django\core\urlresolvers.py in is_valid_path
resolve(path, urlconf)
...
▶ Local vars
c:\Python27\lib\site-packages\django\core\urlresolvers.py in resolve
return get_resolver(urlconf).resolve(path)
...
▶ Local vars
c:\Python27\lib\site-packages\django\core\urlresolvers.py in resolve
for pattern in self.url_patterns:
...
▶ Local vars
c:\Python27\lib\site-packages\django\core\urlresolvers.py in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
...
▶ Local vars
c:\Python27\lib\site-packages\django\core\urlresolvers.py in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
...
▶ Local vars
c:\Python27\lib\site-packages\django\utils\importlib.py in import_module
__import__(name)
...
▶ Local vars
c:\Python27\Django-1.5\mysite\mysite\urls.py in <module>
('^hello/$', hello),
...