我正在try 将daisyUI样式应用到我的Django Web应用程序项目中,并且我肯定了解样式的作用:在我的例子中,我try 将一些daisyUI样式添加到由Django表单动态生成的输入文本字段中:
#forms.py
class ProductForm(forms.ModelForm):
class Meta:
model = Product
fields = '__all__'
widgets = {
'title': forms.TextInput(attrs={'class': 'form-control input input-primary w-full max-w-xs', 'placeholder':'Title'}),
'description': forms.Textarea(attrs={'class': 'textarea textarea-primary w-full'})
}
...
关于这个daisyUI docs page,I should have a rounded bordered input field(与文本区域相同的 idea ).
在我的模板103的表单标记内添加{{form.title}}
.
样式似乎在某处被覆盖,但我无法确定这是从哪里来的……
我用我的代码行得到了"What I Want"的屏幕截图
更多可能有用的信息:
- 在我的电脑本地,我安装了Django-Browser-ReLoad.
- 我的trawind.config.js文件如下所示:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["../**/templates/**/*.html"],
theme: {
extend: {},
},
daisyui: {
themes: ['light', 'dark'],
},
plugins: [require("@tailwindcss/typography"), require("daisyui")],
}
-
我确实try 了重新运行
npm run tailwind-watch
,使用cmd+shift+R
刷新网页,并在每次进行一些更改以查看样式是否正确应用时重新运行‘pythonManage.py runserver` -
我还try 使用这个预先创建的django project(顺便说一句,这是一个很好的举措!)并编辑模板,添加一个表单,结果出现了相同的样式问题.
当寻找一些类似的问题(如this one)时,他们的样式问题似乎起源于tailwind form plugin. But in my case I'm not using it..!的使用
你知道这个问题可能来自哪里吗?
(我希望我的解释足够清楚,因为我没有开发人员的背景,而且到目前为止我"最常用的"编程语言是Python)
预先感谢您的友好回答和帮助?