好的,我正在关注如何使用django进行练习的wiki教程。我使用Python 2.7和Django 1.6.4。我正在尝试运行服务器以便我可以刷新页面,但我突然收到错误"ImportError: No module named wiki."
我已经搜索了这里的所有答案,奇怪的是,我的项目中有一个名为Wiki的子目录,里面有一个 __ init __。py 文件。这是我的目录:
wikicamp (project)
wiki
__init__.py
admin.py
models.py
tests.py
views.py
wikicamp
__init__.py
settings.py
urls.py
wsgi.py
dbsqlite3
manage.py
我的 settings.py 文件INSTALLED_APPS
如下所示:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'wiki',
)
我已将其作为'wikicamp.wiki
'和'wiki'
进行了尝试,我对两者都做了同样的事情。它甚至不让我启动开发服务器,当我输入python manage.py runserver
时出现错误。我确保我在正确的目录中。
以下是我从中得到的所有信息:
PS C:\python27\Lib\site-packages\django\bin\wikicamp> python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line 399, in execute_from_command_line
utility.execute()
File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\Python27\lib\site-packages\django\core\management\base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "c:\Python27\lib\site-packages\django\core\management\base.py", line 280, in execute
translation.activate('en-us')
File "c:\Python27\lib\site-packages\django\utils\translation\__init__.py", line 130, in activate
return _trans.activate(language)
File "c:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 188, in activate
_active.value = translation(language)
File "c:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "c:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 159, in _fetch
app = import_module(appname)
File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 40, in import_module
__import__(name)
ImportError: No module named wiki
答案 0 :(得分:1)
我正在学习您正在学习的相同教程。你只需要转到你的wikicamp / url.py文件并编辑patterns
dict为:
r'^wikicamp/(?P<page_name>[^/]+)/edit/$', 'wiki.views.edit_page'
而不是:
r'^wikicamp/(?P<page_name>[^/]+)/edit/$', 'wikicamp.wiki.views.edit_page'