推荐学习书目
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
P9
V2EX  ›  Python

DJango 表单字段添加 Class 最干净的做法

  •  
  •   P9 · Feb 20, 2016 · 2332 views
    This topic created in 3741 days ago, the information mentioned may be changed or developed.

    分享一个 包 https://github.com/kmike/django-widget-tweaks

    避免 Python Code 层面修改代码
    从此告别
    """
    def init(self, *args, **kwargs):
    super(SampleClass, self).init(*args, **kwargs)
    self.fields['name'].widget.attrs['class'] = 'my_class'

    """"

    在模版层面即可添加!
    多么 DRY 的做法!

    1 replies    2016-02-21 04:13:21 +08:00
    pynix
        1
    pynix  
       Feb 21, 2016
    貌似还不错。。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3017 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 13:23 · PVG 21:23 · LAX 06:23 · JFK 09:23
    ♥ Do have faith in what you're doing.