当使用 django_summernote 时,我尝试为我的博客 django 制作编辑器,但当 ckeditor django 没有错误但不显示编辑器所以如何修复它
表单.py 使用 SummernoteInplaceWidget 时显示但使用 CKEditorWidget 时不显示并且 textarea 输入隐藏
from django_summernote.widgets import SummernoteWidget, SummernoteInplaceWidget
from ckeditor.widgets import CKEditorWidget
class NewTopicForm(forms.ModelForm):
# content = forms.CharField(widget=SummernoteInplaceWidget())
content = forms.CharField(widget=CKEditorWidget())
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['author'].widget.attrs.update(
{'class': 'd-none'})
self.fields['author'].label = ''
self.fields['author'].required = False
self.fields['slug'].required = False
class Meta:
model = Topic
fields = ('title','image', 'author', 'content','NotfFaV','slug')
widgets = {
'title': forms.Textarea(attrs={'class': 'ml-3 mb-3 form-control border-0 read-more rounded-0', 'rows': '1', 'placeholder': 'اضف تعلق'}),
}
urls.py
path('ckeditor/', include('ckeditor_uploader.urls')),
views.py
def home(request):
topic_form = NewTopicForm()
return render(request, 'forum/home.html', { 'topic_form': topic_form })
home.html
{{topic_form.media}}
{{topic_form.content}}
答案 0 :(得分:0)
从 settings.py 中删除或更改路径
import cv2 as cv
import numpy as np
import pyautogui
import time
from threading import Thread
healHk = 'F2'
healHk2 = 'F1'
manaHk = 'F3'
hasteHk = 'F7'
doHeal = 'yes'
doMana = 'yes'
doHaste = 'yes'
spellHk1 = 'F4'
spellHk2 = 'F5'
time.sleep(2)
def healer():
manaPixel = (83, 80, 218)
healthPixel = (241, 97, 97)
hastePixel = (249, 249, 248)
im = pyautogui.screenshot()
matchMana = im.getpixel((1175, 160))
matchHp = im.getpixel((1204, 148))
matchHp2 = im.getpixel((1163, 148))
matchHaste = im.getpixel((597, 63))
if matchHp2 != healthPixel and doHeal == 'yes':
time.sleep(.6)
pyautogui.press(healHk2)
time.sleep(.6)
if matchMana != manaPixel and doMana == 'yes':
pyautogui.press(manaHk)
time.sleep(.6)
if matchHp != healthPixel and matchHp2 == healthPixel and doHeal == 'yes':
time.sleep(.6)
pyautogui.press(healHk)
time.sleep(.6)
if matchHaste != hastePixel and doHaste == 'yes':
time.sleep(.6)
pyautogui.press(hasteHk)
time.sleep(1)
def attacker():
greenFollow = (92, 255, 92)
monsterPixel = (187, 214, 40)
monsterLoc = (10, 49)
attackBorder = (255, 0, 0)
im = pyautogui.screenshot()
matchFollow = im.getpixel((1262, 202))
matchMonster = im.getpixel(monsterLoc)
matchAttackRight = im.getpixel((23, 48))
if matchFollow != greenFollow:
time.sleep(.6)
pyautogui.leftClick(1262, 204)
time.sleep(1)
pyautogui.moveTo(1090, 204, duration=.3)
if matchMonster == monsterPixel and matchAttackRight != attackBorder:
pyautogui.press('space')
time.sleep(.6)
if matchAttackRight == attackBorder:
time.sleep(.6)
pyautogui.press(spellHk1)
time.sleep(1)
pyautogui.press(spellHk2)
time.sleep(1)
while True:
x = Thread(target=healer)
x.start()
attacker()
if cv.waitKey(1) == ord('q'):
cv.destroyAllWindows()
break