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


Python ManyToManyField.register_lookup方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.db.models.fields.related import ManyToManyField [as 别名]
# 或者: from django.db.models.fields.related.ManyToManyField import register_lookup [as 别名]
    template = '%(expressions)s'
    arg_joiner = ' - '
    arity = 2

    def __init__(self, start, end):
        super(DateDiff, self).__init__(start, end)

    def as_microsoft(self, compiler, connection):
        self.template = 'cast(DateDiff(day,%(expressions)s) as float)* -1 *24*60*60*1000.0*1000.0' # Convert to microseconds as used by Django DurationField'
        self.arg_joiner = ', '
        return super(DateDiff, self).as_sql(compiler, connection)

    def as_sql(self, compiler, connection, function=None, template=None):
        if connection.vendor is 'microsoft':
            return self.as_microsoft(compiler, connection)
        return super(DateDiff, self).as_sql(compiler, connection)


class NotEqual(Lookup):
    lookup_name = 'ne'

    def as_sql(self, qn, connection):
        lhs, lhs_params = self.process_lhs(qn, connection)
        rhs, rhs_params = self.process_rhs(qn, connection)
        params = lhs_params + rhs_params
        return '%s != %s' % (lhs, rhs), params
Field.register_lookup(NotEqual)
RelatedField.register_lookup(NotEqual)
ForeignObject.register_lookup(NotEqual)
ManyToManyField.register_lookup(NotEqual)
开发者ID:LegoStormtroopr,项目名称:django-data-interrogator,代码行数:32,代码来源:db.py


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