本文整理汇总了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)