Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 覆盖Django中不带模型的Textarea。仅在形式上_Python_Django - Fatal编程技术网

Python 覆盖Django中不带模型的Textarea。仅在形式上

Python 覆盖Django中不带模型的Textarea。仅在形式上,python,django,Python,Django,我想更改Textarea的默认大小。我读到: [ 但我不知道我怎么能推翻它 我的代码: forms.py: from django import forms class KarForm(forms.Form): message = forms.CharField( widget=forms.Textarea, label="", ) views.py: from django.shortcuts import render from .for

我想更改Textarea的默认大小。我读到: [ 但我不知道我怎么能推翻它

我的代码: forms.py:

from django import forms 

class KarForm(forms.Form):
    message = forms.CharField(
        widget=forms.Textarea,
        label="",
    )
views.py:

from django.shortcuts import render
from .forms import KarelForm

def home(request):
    form = KarForm()
    context = {
    "form": form
    }
    return render(request, "form.html", context)
选中。您可以添加类或其他属性,例如:

class CommentForm(forms.Form):
    name = forms.CharField(widget=forms.TextInput(attrs={'class': 'special'})) # then you define the class in your css file
    url = forms.URLField()
    comment = forms.CharField(widget=forms.TextInput(attrs={'size': '40'}))
选中。您可以添加类或其他属性,例如:

class CommentForm(forms.Form):
    name = forms.CharField(widget=forms.TextInput(attrs={'class': 'special'})) # then you define the class in your css file
    url = forms.URLField()
    comment = forms.CharField(widget=forms.TextInput(attrs={'size': '40'}))