2013-02-09 135 views
0

我使用Django 1.4.2工作,我得到了以下錯誤消息:IndentationError消息的Django

enter image description here有人能告訴我哪些文件具有縮進問題?我試過 python -m tabnanny -v manage.py,我得到了「清潔健康證明」,所以我認爲該文件沒有問題。 而我從來沒有碰過其他2個文件。

我在Python上使用Python 2.7.2和Django 1.4.2。

這裏就是整個importlibs.py:

def _resolve_name(name, package, level): 
"""Return the absolute name of the module to be imported.""" 
if not hasattr(package, 'rindex'): 
    raise ValueError("'package' not set to a string") 
dot = len(package) 
for x in xrange(level, 1, -1): 
    try: 
     dot = package.rindex('.', 0, dot) 
    except ValueError: 
     raise ValueError("attempted relative import beyond top-level " 
          "package") 
return "%s.%s" % (package[:dot], name) 

def import_module(name, package=None): 
"""Import a module. 

The 'package' argument is required when performing a relative import. It 
specifies the package to use as the anchor point from which to resolve the 
relative import to an absolute import. 

""" 
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]  
+0

它不是任何Django文件。它是您項目中的文件之一。 – 2013-02-09 01:41:09

+0

@Daniel我們能從錯誤信息中知道哪一個?我爲我的所有項目文件嘗試了'tabnanny -v ',並且都輸出了「Clean bill of health」消息。 – Dombey 2013-02-09 02:12:27

+0

其實,我回過頭來看,它好像是django/utils/importlib.py那樣有問題。無法想象爲什麼。 – 2013-02-09 02:17:39

回答

0

在Django中使用Tab鍵是一個不好的做法。爲了解決你的問題,你只能使用空格,我想4個空格。嘗試退格你的代碼,你會發現它是製表符縮進,只使用空格。