AttributeError: 模块 'profile' 没有属性 'run'

mic*_*ich 3 python django django-apps django-authentication django-2.2

所以我有一个名为 Profile 的扩展用户模型(扩展 AbstractUser)。这是在一个名为“配置文件”的单独应用程序中。我插入标准登录并意识到它正在寻找一个“配置文件”应用程序名称作为标准,所以我重命名了它(目录、代码、数据库架构),我认为应该可以工作。app_name 实际上已经在 apps.py 中设置为“profile”,因此不需要重命名 url 引用。

没有骰子。我收到标题中的错误。

所以我删除了所有迁移(我现在还可以这样做:))并删除了我目前正在使用的 sqlite 数据库,我想我只是重新运行迁移并重新创建所有内容。

同样的错误。

堆栈跟踪是:

?  python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\django\core\management\base.py", line 361, in execute
    self.check()
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\django\core\management\base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\django\core\management\base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\debug_toolbar\apps.py", line 18, in check_middleware
    from debug_toolbar.middleware import DebugToolbarMiddleware
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\debug_toolbar\middleware.py", line 12, in <module>
    from debug_toolbar.toolbar import DebugToolbar
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\debug_toolbar\toolbar.py", line 141, in <module>
    urlpatterns = DebugToolbar.get_urls()
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\debug_toolbar\toolbar.py", line 134, in get_urls
    for panel_class in cls.get_panel_classes():
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\debug_toolbar\toolbar.py", line 116, in get_panel_classes
    import_string(panel_path) for panel_path in dt_settings.get_panels()
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\debug_toolbar\toolbar.py", line 116, in <listcomp>
    import_string(panel_path) for panel_path in dt_settings.get_panels()
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\mjnic\.virtualenvs\pyp-E_0Se9Bl\lib\site-packages\debug_toolbar\panels\profiling.py", line 1, in <module>
    import cProfile
  File "D:\Python\Python37-32\Lib\cProfile.py", line 22, in <module>
    run.__doc__ = _pyprofile.run.__doc__
AttributeError: module 'profile' has no attribute 'run'
Run Code Online (Sandbox Code Playgroud)

作为重命名的一部分,我错过了什么?

我错过的任何其他信息会有所帮助吗?(我已经搜索了“配置文件”的任何实例,但现在所有内容都已正确重命名,并且该应用程序在此之前运行正常,因此纯粹是重命名将其搞砸了)。

编辑:“配置文件”是否与某些内部 python 例程冲突?python安装下的那个cProfile.py文件定义为

#! /usr/bin/env python3

"""Python interface for the 'lsprof' profiler.
   Compatible with the 'profile' module.
"""
Run Code Online (Sandbox Code Playgroud)

现在这与我的项目没有任何关系?我是否只需要将我的应用程序/扩展用户模型称为“个人资料”以外的其他内容?

Roh*_*ami 15

就我而言,它是profile.py文件。

删除该文件并重试。


mic*_*ich 12

好的。所以是的,这是一个命名冲突。我已将我的“配置文件”模型和“配置文件”应用程序重命名为“UserProfile”和“user_profile”,并相应地更新了所有内容。现在这一切似乎都有效......

只是在这里提供一个答案,以防将来有人遇到同样的问题!