سؤال

New to python and django .i want to understand the code of django-registration module for this i want to debug the value in code. So i m stuck here that

i = path.rfind('.')
    module, attr = path[:i], path[i+1:]

print {i}
#or
import pdb; pdb.set_trace()

my registration form is not showing and gives error .

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)

How can i debug or see the value of i .

This is the code :

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()
هل كانت مفيدة؟

المحلول

Indentations matter a lot in python, and as the error suggests, you have an indentation problem. You should only indent when creating a new block of code, for example after if, for or while statements.

Just remove the whitespaces before module:

i = path.rfind('.')
module, attr = path[:i], path[i+1:]

print i
#or
import pdb; pdb.set_trace()
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top