python和django的新手。我想了解django-registration模块的代码,我想调试代码中的值。 所以我被困在这里
i = path.rfind('.')
module, attr = path[:i], path[i+1:]
print {i}
#or
import pdb; pdb.set_trace()
我的注册表单没有显示并出错。
IndentationError at /accounts/register/
unexpected indent (__init__.py, line 19)
Request Method: GET
Request URL: http://50.56.78.125:8000/accounts/register/
Django Version: 1.3.1
Exception Type: IndentationError
Exception Value:
unexpected indent (__init__.py, line 19)
我如何调试或查看i的值。
这是代码:
i = path.rfind('.')
module, attr = path[:i], path[i+1:]
try:
mod = import_module(module)
except ImportError, e:
raise ImproperlyConfigured('Error loading registration backend %s: "%s"' % (module, e))
try:
backend_class = getattr(mod, attr)
except AttributeError:
raise ImproperlyConfigured('Module "%s" does not define a registration backend named "%s"' % (module, attr))
return backend_class()
答案 0 :(得分:1)
缩进在python中很重要,正如错误所示,你有一个缩进问题。您只应在创建新代码块时缩进,例如在if
,for
或while
语句之后。
只需删除module
之前的空格:
i = path.rfind('.')
module, attr = path[:i], path[i+1:]
print i
#or
import pdb; pdb.set_trace()