当我在PowerShell中运行python manage.py runserver
,我得到了以下错误:IndentationError运行manage.py runserver命令Django的时候
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line
__import__(name)
IndentationError: unexpected indent
但是,我从来没有触及该文件之前,当我打开记事本该文件++它显示 这样的:
if name.startswith('.'):
if not package:
raise TypeError("relative imports require the 'package' argument")
level = 0
for character in name:
if character != '.':
break
level += 1
name = _resolve_name(name[level:], package, level)
__import__(name) #LINE 35
return sys.modules[name]`
出了什么问题?我正在使用Python 2.7和Django 1.4.2在Windows Vista x32上工作 我感谢您的帮助。
这里是settings.py
下的数据库信息:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'demo', # Or path to database file if using sqlite3.
'USER': '****', # Not used with sqlite3.
'PASSWORD': '*****', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
}
}
我也取消注释'django.contrib.admin'
在同一个文件中。我在“urls.py”中取消注释url(r'^admin/', include(admin.site.urls)),
以启用管理员。这里是urls.py
,这是我从python manage.py startproject
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'^$', 'demo.views.home', name='home'),
# url(r'^demo/', include('demo.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)),
)
已删除答案 - 我不知道发生了什么事。 – 2013-02-08 20:48:32
问题不在于importlib,它在任何文件importlib试图导入。你提到urls.py的更改 - 你应该发布。 – 2013-02-08 21:07:04
我想'蟒蛇-m tabnanny -v'的manage.py,settings.py和urls.py和我'health'的清洁提单,所以我认为这些文件是好的。 –
Dombey
2013-02-09 00:59:22