我怎样才能读取从引导“输入”元素和引导程序“下拉列表”到Django? [英] how can i read the values from bootstrap "input" element, and bootstrap "drop down list" to django?

查看:92
本文介绍了我怎样才能读取从引导“输入”元素和引导程序“下拉列表”到Django?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将大括号放在某处读取这些值,或者我应该使用其他方法?

is it possible to place the curly brackes somewhere to read these values, or should i use some other method ?

bootstrap "input" form group :
============================
<div class="form-group">
            <input class="form-control input-lg" type="text" placeholder="Amount to invest (Example: 10000)"  />
</div>


推荐答案

解决此问题我使用了Django的小部件功能

to resolve the issue I used Django's widget feature

在form.py中,我为输入字段放置了以下标记:

in form.py I placed the following markup for the input field:


金额
= forms.CharField( widget = forms.TextInput(attrs = {'type':'number' 'class':'form-control
input-lg'
,placeholder:Enter Amount}))

amount =forms.CharField(widget=forms.TextInput(attrs={'type':'number','class':'form-control input-lg',"placeholder":"Enter Amount"}))

这允许我放置下面使用的django模板:

this allowed me to place the following the django template used:

<div class="row" style="margin-top: 50px;">
  <div class="col-md-4"></div>   

  <div class="col-md-4" style="vertical-align: top;margin:0;padding:0;">
        <div class="form-group">
                {{ form.amount }}
        </div>
  </div>                               

  <div class="col-md-4"></div>
   </div><!-- /.row -->

这是为我生成的 - 等价于HTML行的HTML

this produced for me - an HTML equivalent to the HTML row

<input class="form-control input-lg" type="text" placeholder="Enter amount"  />

这篇关于我怎样才能读取从引导“输入”元素和引导程序“下拉列表”到Django?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆