fields.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:djangocms-attributes-field 作者: divio 项目源码 文件源码
def contribute_to_class(self, cls, name, **kwargs):
        """
        Adds a @property: «name»_str that returns a string representation of
        the attributes ready for inclusion on an HTML element.
        """
        super(AttributesField, self).contribute_to_class(cls, name, **kwargs)
        # Make sure we're not going to clobber something that already exists.
        property_name = '{name}_str'.format(name=name)
        if not hasattr(cls, property_name):
            str_property = curry(self.to_str, field_name=name)
            setattr(cls, property_name, property(str_property))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号