- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在我的电脑上开发一个 Django 项目,然后我创建了一个名为“register”的应用程序,当我尝试运行 manage.py runserver 时,我收到一个奇怪的错误:我使用Python 3.8.3。当我添加注册表单时出现此错误。
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 377, in execute
django.setup()
File "C:\Python38\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python38\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Python38\lib\site-packages\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "C:\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'main'
我的设置.py:
DEBUG = True
ALLOWED_HOSTS = ['*']
SETTINGS_PATH = os.path.dirname(os.path.dirname(__file__))
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'simple2',
"crispy_forms",
'main.apps.MainConfig',
'register.apps.RegisterConfig',
'register'
]
...
最佳答案
我猜测您没有配置 WSGI 应用程序,因为 Django 的应用程序引擎会在名为 main.py
的文件中查找 app
变量。您可以通过以下两种方式来看待这个问题:
包含您的 WSGI 申请
您仍然可以创建一个名为 main.py
的文件,其中包含 app 变量
。您不需要编写任何内容,只需导入它即可(假设您的项目名称是 projekt
:
from projekt.wsgi import main as app
添加自定义入口点
如 Google's Appengine 所示:
entrypoint
: Optional. The command that is executed when your app starts. For your app to receive HTTP requests,entrypoint
should contain a command which starts a web server that listens on the port specified by the PORT environment variable. If you do not specify anentrypoint
, App Engine will configure and start the Gunicorn webserver.
默认值与您的需要之间的比较:
# default
entrypoint: gunicorn -b :$PORT main:app
# What you need
entrypoint: gunicorn -b :$PORT demosite.wsgi:main
关于python - Django 没有名为 'main' 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63072297/
这个问题在这里已经有了答案: Is Git’s "master" branch name more than just a name? (3 个回答) What will break if I don
我使用了Plone实例文件夹的“bin /”目录中的“paster”命令来创建一个名为“MyApp”的plone应用程序(来自模板),该命令是: (from instance's root folde
我正在尝试覆盖 FOSUserBundle 的用户映射的两个属性。 use FOS\UserBundle\Model\User as BaseUser; ... use Symfony\Bridge\
工作通过 these posts让我认为我了解自我类型,至少在某种程度上。 所以我创建了一个按预期失败的例子: scala> trait A { val v = "a" } defined trait
我在 IntelliJ 中有一个 JavaFX Maven 项目,它使用 Hibernate。当应用程序启动时,我收到以下错误消息: No persistence provider for entit
我正在尝试构建一个数据透视表,并使用开源代码并摸索着这个函数。record[] 如何传递给这个函数?似乎没有经过或任何声明。怎么能直接来呢? 完整代码可以在这里找到https://github.com
我的应用程序有 abc.com 链接,这是一个主页和 abc.com/user123(有一个动态部分),这是一个用户登录的特定配置文件页面。 早些时候,我通过这样做实现了这一点: this.route
当我在使用 mac book pro 的 Android Studio 上设置 Flutter Sdk 路径时,我遇到错误 Flutter SDK 路径未给出(并且打开一个弹出窗口并显示消息“名为‘F
我刚刚设置了 Postgres 供我网络上的不同用户使用。每个用户都有自己的用户名/密码/数据库,但是当我连接到 Pg 时,我还可以看到一个“postgres”数据库(甚至可以创建表等)。我试图从公众
我正在尝试从 MySQL 数据库中获取一些数据。所以我要做的是: select * from my_table where 'to' ='0000-00-00 00:00:00'; 这给了我空集,但我
我有一个名为“索引”的表。我意识到这是 MySQL 中的关键字,想知道如何在查询中引用该表? 我的错误: #1064 - You have an error in your SQL syntax; c
我在机器 myuniversity.edu 上设置了一个远程 mysql 数据库服务器,服务器名为“localhost”。我在上面有一个名为“MyDatabase”的数据库。 I want to co
我正在尝试使用 Android NDK 构建应用程序。我已按照所有步骤操作,一切正常,正在制作 .so 文件。但是在 Eclipse 中,当我尝试清理项目时出现以下错误: The file does
我正在重写 UIImage 类方法 init(named:)。我的目标是能够检索图像的文件名。 代码看起来像这样: class UIImageWithFileName: UIImage { l
@ThreadSafe public class A { } 这个注解实际上使类线程安全还是只是为了提高可读性? 最佳答案 参见 @ThreadSafe Annotation : Place this
当我将第二个表(dtResult)添加到数据集时出现错误 名为“Table”的数据表已属于此数据集。 DataTable dtSession = new DataTable(); DataTable
这个问题可能看起来重复,但略有不同。在 SO 的所有其他问题中,我注意到他们注册了多条路线。但就我而言,我只有一条路线。 我正在创建 asp.net webapi(框架 4.5)并且在 Registe
我最近将 Microsoft.AspNet.WebApi.WebHost 添加到 MVC WebAPI 项目中,这将允许我使用 [Route("api/some-action")] 归因于我的行动。我
我有一个名为“异常”的命名空间的问题 让我们考虑以下示例标题: #include namespace exception { struct MyException : public std::e
我昨天安装了 Nuget 1.2,今天,当我尝试安装 Entity Framework 包时,我在包管理器控制台中遇到了以下问题: PM> install-package entityframewor
我是一名优秀的程序员,十分优秀!