我是 wagtail 新手,正在关注官方和 YouTube 教程(yt 跳过安装 libjpeg 和 zlib 的说明,但当我尝试时,它说 Pillow 已包含它们);运行在windows10上,使用最新的python、最新的wagtail、最新的django;卡在第一个位置,在运行 makemigrations 或 migrate 或 runserver 时仍然遇到相同的问题:
File "C:\Users\TalkyWalky\Desktop\Workspace\bloggyblog\home\models.py", line 14, in
HomePage
banner_subtitle = models.RichTextField(features=["bold", "italic"])
AttributeError: module 'django.db.models' has no attribute 'RichTextField'
Run Code Online (Sandbox Code Playgroud)
这是我的 models.py:
from django.db import models
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
class HomePage(Page):
"""Homepage model."""
body = RichTextField(blank=True)
templates = "templates/home/home_page.html"
max_count = 1
banner_title = models.CharField('Body', blank=True)
banner_subtitle = models.RichTextField(features=["bold", "italic"])
banner_image = models.ForeignKey(features=
"wagtailImages.Image",
null=False,
blank=False, …Run Code Online (Sandbox Code Playgroud) 首先,我还不知道问题出在前端还是后端,但看来后端的可能性更大。
我使用 django-channels 构建了一个 Django 应用程序,通过 websocket 连接将数据包发送到前端react.js SPA;我之前还构建了一个简单的 vanilla-javascript 客户端(由 Django 提供),并且它没有这个问题。
问题是,我在打开时在 Firefox 控制台中收到此错误(它们随机切换位置,表明它们同时发生):
Firefox can't establish a connection to the server at ws://localhost:8000/ws/XY_Broadcast/. App.jsx:32
The connection to ws://localhost:8000/ws/XY_Broadcast/ was interrupted while the page was loading. App.jsx:32
Run Code Online (Sandbox Code Playgroud)
使用 Brave 浏览器(基于 Chromium),我得到这个:
(warning) App.jsx:69 WebSocket connection to 'ws://localhost:8000/ws/XY_Broadcast' failed: WebSocket is closed before the connection is established.
(error)App.jsx:38 WebSocket connection to 'ws://localhost:8000/ws/XY_Broadcast' failed:
Run Code Online (Sandbox Code Playgroud)
但奇怪的是,我的页面似乎可以打开并工作 - 它会在打开时和在一段时间后接收数据时打印消息。 Websocket 错误代码为 1006。
我尝试过的: