【问题标题】:Why can't I use "profile" as an app name?为什么我不能使用“个人资料”作为应用名称?
【发布时间】:2022-07-06 21:55:55
【问题描述】:

我需要一个配置文件来扩展 Django 用户对象,所以我想创建一个应用程序来包含配置文件对象和相关视图,然后按照Django doc 进行操作,但我明白了

./manage.py startapp profile
CommandError: 'profile' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.

我在 INSTALLED_APPS 中没有名为 profile 的应用,我不知道应该在什么上下文中解释此消息。有人可以帮忙吗?

(是的,我可以将其称为 userprofile 或 xxx_profile,但我想了解我为什么需要这样做)

【问题讨论】:

    标签: django


    【解决方案1】:

    它与标准库模块配置文件冲突:

    https://docs.python.org/3/library/profile.html

    【讨论】:

      【解决方案2】:

      它与一个已经存在的库冲突,不是你制作的

      任何其他不是库的名称都可以

      【讨论】:

        【解决方案3】:

        如果你有一个名为 math 的应用程序,当 python 尝试导入它时,我会想一想,它将在 python 中导入你的 app 或 math 模块模块必须具有唯一的名称

        您可以将其命名为profile_app

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-09-30
          • 1970-01-01
          • 2015-11-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多