当前位置: 首页>>代码示例>>Python>>正文


Python LOOKUP_SEP.join方法代码示例

本文整理汇总了Python中django.db.models.sql.query.LOOKUP_SEP.join方法的典型用法代码示例。如果您正苦于以下问题:Python LOOKUP_SEP.join方法的具体用法?Python LOOKUP_SEP.join怎么用?Python LOOKUP_SEP.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.db.models.sql.query.LOOKUP_SEP的用法示例。


在下文中一共展示了LOOKUP_SEP.join方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: quote

# 需要导入模块: from django.db.models.sql.query import LOOKUP_SEP [as 别名]
# 或者: from django.db.models.sql.query.LOOKUP_SEP import join [as 别名]
def quote(s):
    """
    Ensure that primary key values do not confuse the admin URLs by escaping
    any '/', '_' and ':' characters. Similar to urllib.quote, except that the
    quoting is slightly different so that it doesn't get automatically
    unquoted by the Web browser.
    """
    cls_str = str if six.PY3 else basestring
    if not isinstance(s, cls_str):
        return s
    res = list(s)
    for i in range(len(res)):
        c = res[i]
        if c in """:/_#?;@&=+$,"<>%\\""":
            res[i] = '_%02X' % ord(c)
    return ''.join(res) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:18,代码来源:util.py

示例2: unquote

# 需要导入模块: from django.db.models.sql.query import LOOKUP_SEP [as 别名]
# 或者: from django.db.models.sql.query.LOOKUP_SEP import join [as 别名]
def unquote(s):
    """
    Undo the effects of quote(). Based heavily on urllib.unquote().
    """
    cls_str = str if six.PY3 else basestring
    if not isinstance(s, cls_str):
        return s
    mychr = chr
    myatoi = int
    list = s.split('_')
    res = [list[0]]
    myappend = res.append
    del list[0]
    for item in list:
        if item[1:2]:
            try:
                myappend(mychr(myatoi(item[:2], 16)) + item[2:])
            except ValueError:
                myappend('_' + item)
        else:
            myappend('_' + item)
    return "".join(res) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:24,代码来源:util.py

示例3: display_for_field

# 需要导入模块: from django.db.models.sql.query import LOOKUP_SEP [as 别名]
# 或者: from django.db.models.sql.query.LOOKUP_SEP import join [as 别名]
def display_for_field(value, field):
    from xadmin.views.list import EMPTY_CHANGELIST_VALUE

    if field.flatchoices:
        return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
        return boolean_icon(value)
    elif value is None:
        return EMPTY_CHANGELIST_VALUE
    elif isinstance(field, models.DateTimeField):
        return formats.localize(tz_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, models.FloatField):
        return formats.number_format(value)
    elif isinstance(field.rel, models.ManyToManyRel):
        return ', '.join([smart_text(obj) for obj in value.all()])
    else:
        return smart_text(value) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:25,代码来源:util.py

示例4: display_for_field

# 需要导入模块: from django.db.models.sql.query import LOOKUP_SEP [as 别名]
# 或者: from django.db.models.sql.query.LOOKUP_SEP import join [as 别名]
def display_for_field(value, field):
    from xadmin.views.list import EMPTY_CHANGELIST_VALUE

    if field.flatchoices:
        return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
        return boolean_icon(value)
    elif value is None:
        return EMPTY_CHANGELIST_VALUE
    elif isinstance(field, models.DateTimeField):
        return formats.localize(tz_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, models.FloatField):
        return formats.number_format(value)
    elif isinstance(field.remote_field, models.ManyToManyRel):
        return ', '.join([smart_text(obj) for obj in value.all()])
    else:
        return smart_text(value) 
开发者ID:Superbsco,项目名称:weibo-analysis-system,代码行数:25,代码来源:util.py

示例5: quote

# 需要导入模块: from django.db.models.sql.query import LOOKUP_SEP [as 别名]
# 或者: from django.db.models.sql.query.LOOKUP_SEP import join [as 别名]
def quote(s):
    """
    Ensure that primary key values do not confuse the admin URLs by escaping
    any '/', '_' and ':' characters. Similar to urllib.quote, except that the
    quoting is slightly different so that it doesn't get automatically
    unquoted by the Web browser.
    """
    cls_str = str
    if not isinstance(s, cls_str):
        return s
    res = list(s)
    for i in range(len(res)):
        c = res[i]
        if c in """:/_#?;@&=+$,"<>%\\""":
            res[i] = '_%02X' % ord(c)
    return ''.join(res) 
开发者ID:mtianyan,项目名称:Mxonline3,代码行数:18,代码来源:util.py

示例6: unquote

# 需要导入模块: from django.db.models.sql.query import LOOKUP_SEP [as 别名]
# 或者: from django.db.models.sql.query.LOOKUP_SEP import join [as 别名]
def unquote(s):
    """
    Undo the effects of quote(). Based heavily on urllib.unquote().
    """
    cls_str = str
    if not isinstance(s, cls_str):
        return s
    mychr = chr
    myatoi = int
    list = s.split('_')
    res = [list[0]]
    myappend = res.append
    del list[0]
    for item in list:
        if item[1:2]:
            try:
                myappend(mychr(myatoi(item[:2], 16)) + item[2:])
            except ValueError:
                myappend('_' + item)
        else:
            myappend('_' + item)
    return "".join(res) 
开发者ID:mtianyan,项目名称:Mxonline3,代码行数:24,代码来源:util.py

示例7: unquote

# 需要导入模块: from django.db.models.sql.query import LOOKUP_SEP [as 别名]
# 或者: from django.db.models.sql.query.LOOKUP_SEP import join [as 别名]
def unquote(s):
    """
    Undo the effects of quote(). Based heavily on urllib.unquote().
    """
    if not isinstance(s, basestring):
        return s
    mychr = chr
    myatoi = int
    list = s.split('_')
    res = [list[0]]
    myappend = res.append
    del list[0]
    for item in list:
        if item[1:2]:
            try:
                myappend(mychr(myatoi(item[:2], 16)) + item[2:])
            except ValueError:
                myappend('_' + item)
        else:
            myappend('_' + item)
    return "".join(res) 
开发者ID:Liweimin0512,项目名称:ImitationTmall_Django,代码行数:23,代码来源:util.py

示例8: display_for_field

# 需要导入模块: from django.db.models.sql.query import LOOKUP_SEP [as 别名]
# 或者: from django.db.models.sql.query.LOOKUP_SEP import join [as 别名]
def display_for_field(value, field):
    from xadmin.views.list import EMPTY_CHANGELIST_VALUE

    if field.flatchoices:
        return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
        return boolean_icon(value)
    elif value is None:
        return EMPTY_CHANGELIST_VALUE
    elif isinstance(field, models.DateTimeField):
        return formats.localize(tz_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, models.FloatField):
        return formats.number_format(value)
    elif isinstance(field.rel, models.ManyToManyRel):
        return ', '.join([smart_unicode(obj) for obj in value.all()])
    else:
        return smart_unicode(value) 
开发者ID:Liweimin0512,项目名称:ImitationTmall_Django,代码行数:25,代码来源:util.py

示例9: lookup_field

# 需要导入模块: from django.db.models.sql.query import LOOKUP_SEP [as 别名]
# 或者: from django.db.models.sql.query.LOOKUP_SEP import join [as 别名]
def lookup_field(name, obj, model_admin=None):
    opts = obj._meta
    try:
        f = opts.get_field(name)
    except models.FieldDoesNotExist:
        # For non-field values, the value is either a method, property or
        # returned via a callable.
        if callable(name):
            attr = name
            value = attr(obj)
        elif (
                model_admin is not None
                and hasattr(model_admin, name)
                and name not in ('__str__', '__unicode__')
        ):
            attr = getattr(model_admin, name)
            value = attr(obj)
        else:
            if is_rel_field(name, obj):
                parts = name.split("__")
                rel_name, sub_rel_name = parts[0], "__".join(parts[1:])
                rel_obj = getattr(obj, rel_name)
                if rel_obj is not None:
                    return lookup_field(sub_rel_name, rel_obj, model_admin)
            attr = getattr(obj, name)
            if callable(attr):
                value = attr()
            else:
                value = attr
        f = None
    else:
        attr = None
        value = getattr(obj, name)
    return f, attr, value 
开发者ID:stormsha,项目名称:StormOnline,代码行数:36,代码来源:util.py


注:本文中的django.db.models.sql.query.LOOKUP_SEP.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。