当我试图登录我的管理页面时遇到了这个错误。在
AttributeError at /admin/login/
'tuple' object has no attribute 'rsplit'
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/
Django Version: 1.10
Exception Type: AttributeError
Exception Value:
'tuple' object has no attribute 'rsplit'
Exception Location: C:\Users\Adila\Envs\tryFOUR\lib\site-packages\django\utils\module_loading.py in import_string, line 15
Python Executable: C:\Users\Adila\Envs\tryFOUR\Scripts\python.exe
回溯:
回溯:
^{pr2}$我不知道为什么会出现这个错误,我也不知道如何确切地修复它。我确实会搜索这个错误,而且大多数都是在他们试图运行collectstatic
命令时搜索的。错误是由逗号引起的,我确实删除了此处右括号后面的逗号:
STATICFILES_DIRS= (
os.path.join(os.path.dirname(BASE_DIR), "static", "static")
)
但我还是无法访问我的管理页面。在
我确实追踪到了回溯:
def import_string(dotted_path):
"""
Import a dotted module path and return the attribute/class designated by the
last name in the path. Raise ImportError if the import failed.
"""
try:
module_path, class_name = dotted_path.rsplit('.', 1)
except ValueError:
msg = "%s doesn't look like a module path" % dotted_path
six.reraise(ImportError, ImportError(msg), sys.exc_info()[2])
module = import_module(module_path)
我尝试为用户和超级用户创建自己的自定义注册页。在
初始化.py:
def load_backend(path):
return import_string(path)()
def _get_backends(return_tuples=False):
backends = []
for backend_path in settings.AUTHENTICATION_BACKENDS:
backend = load_backend(backend_path)
backends.append((backend, backend_path) if return_tuples else backend)
if not backends:
raise ImproperlyConfigured(
'No authentication backends have been defined. Does '
'AUTHENTICATION_BACKENDS contain anything?'
)
return backends
def get_backends():
return _get_backends(return_tuples=False)
在我看来你的
STATICFILES_DIRS
是不正确的。如果您参考文档https://docs.djangoproject.com/en/1.11/ref/settings/#staticfiles-dirs,则表明您应该将STATICFILES_DIRS
定义为一个列表:很难诊断原因是什么,因为没有stacktrace,否则您可以准确地找到异常的来源。但我认为这和这个环境有关。在
另外,当你使用一个没有逗号的元组时,它只会像表达式一样计算它。我举个例子:
^{pr2}$如果你用逗号做同样的事情:
对于第二个示例,您将不会得到这样的AssertionError。在
相关问题 更多 >
编程相关推荐