當我在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