models.py 文件源码

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

项目:django-codenerix-products 作者: centrologic 项目源码 文件源码
def __unicode__(self, show_attribute=True):
        value = ''
        if self.attribute.type_value == TYPE_VALUE_BOOLEAN:
            value = bool(self.value) and _('True') or _('False')
        elif self.attribute.type_value == TYPE_VALUE_FREE:
            value = self.value
        elif self.attribute.type_value == TYPE_VALUE_LIST:
            lang = get_language_database()
            field = '{}__description'.format(lang)
            ov = OptionValueAttribute.objects.filter(
                group=self.attribute.list_value,
                pk=int(self.value)
            ).values(
                field
            ).first()
            if ov:
                value = ov[field]
        if show_attribute:
            return u"{}: {}".format(smart_text(self.attribute), smart_text(value))
        else:
            return u"{}".format(smart_text(value))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号