推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
carlosw
V2EX  ›  Python

flask-wtf SelectFiled 相关问题

  •  
  •   carlosw · Nov 25, 2019 · 3237 views
    This topic created in 2386 days ago, the information mentioned may be changed or developed.

    我创建了一个 flask-wtf 的表单,有一项是 selection 类型,choices 选项我想使用一个变量,但是不知道需要怎么传进去。有人知道嘛?

    class Connection(FlaskForm):
        env = SelectField(
            label = '环境选择:  ',
            render_kw={ 'class': 'form-control' },
            choices = [('default', 'default'), ('dev', 'dev'), ('hotfix', 'hotfix')], # 这里查资料都是要写死,不知道怎么使用变量
            default = 'default',
            coerce=str
        )
    
    4 replies    2019-11-26 21:00:19 +08:00
    lbfeng
        1
    lbfeng  
       Nov 26, 2019
    def __init__(self, **kwargs):
    super(Connection, self).__init__(**kwargs)
    self.env.choices = [ ]
    self.env.default =
    coolair
        2
    coolair  
       Nov 26, 2019 via Android
    到 view 里面去设置
    carlosw
        4
    carlosw  
    OP
       Nov 26, 2019
    @altboy 解决了 ,十分感谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6169 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 03:03 · PVG 11:03 · LAX 20:03 · JFK 23:03
    ♥ Do have faith in what you're doing.