Django范围输入而非文本

2024-04-26 13:58:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用django表单,正如您在视图.py文件和结果是有一个文本框。我可以提交数值,然后使用这个数字运行脚本.py等等,我想用一个范围输入来代替文本,这样每次滑块上的值都会改变。在

我的视图.py在

def get_name(request):
form = NameForm()
if request.method == 'POST': 
    a = request.POST['your_name'] # do somethink with the value entered in the form
    print(a)
    a = int(a) 
    while a>0:
        print(a)
        a = a -1

return render(request, 'personal/code2.html', {'form': form})

我的代码2.html

^{pr2}$

还有我的表单.py在

from django import forms

class NameForm(forms.Form):
  your_name = forms.DurationField(label='% Brightness ')

Tags: 文件thedjangonamepyform视图表单