gpt4 book ai didi

django - 类型错误 : __init__() got an unexpected keyword argument 'show_preview'

转载 作者:行者123 更新时间:2023-12-04 10:48:15 25 4
gpt4 key购买 nike

我在 Django 1.9 中遇到这个错误

in PostForm
content = forms.CharField(widget=PagedownWidget(show_preview=False))
TypeError: __init__() got an unexpected keyword argument 'show_preview'

表单.py

class PostForm(forms.ModelForm):
content = forms.CharField(widget=PagedownWidget(show_preview=False))
publish = forms.DateField(widget=forms.SelectDateWidget)
class Meta:
model = Post
fields = [
"title",
"content",
"image",
"draft",
"publish",
]

虚拟环境安装的依赖美元点卡住

certifi==2019.11.28
Django==1.9
django-crispy-forms==1.8.1
django-filter==2.2.0
django-markdown-deux==1.0.5
django-pagedown==2.0.3
djangorestframework==3.11.0
Markdown==3.1.1
markdown2==2.3.1
olefile==0.46
Pillow==6.2.1

最佳答案

使用attrs-- (Django Doc)将值传递给小部件的参数

widget=PagedownWidget(<b>attrs={"show_preview":False}</b>)

关于django - 类型错误 : __init__() got an unexpected keyword argument 'show_preview' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59602193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com