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


Python expressions.Value类代码示例

本文整理汇总了Python中django.db.models.expressions.Value的典型用法代码示例。如果您正苦于以下问题:Python Value类的具体用法?Python Value怎么用?Python Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self, expression, distinct=False, **extra):
     if expression == "*":
         expression = Value(expression)
         expression._output_field = IntegerField()
     super(Count, self).__init__(
         expression, distinct="DISTINCT " if distinct else "", output_field=IntegerField(), **extra
     )
开发者ID:Morfyo,项目名称:JAVASCRIPT,代码行数:7,代码来源:aggregates.py

示例2: process_rhs

 def process_rhs(self, compiler, connection):
     value = self.rhs
     if self.bilateral_transforms:
         if self.rhs_is_direct_value():
             # Do not call get_db_prep_lookup here as the value will be
             # transformed before being used for lookup
             value = Value(value, output_field=self.lhs.output_field)
         value = self.apply_bilateral_transforms(value)
         value = value.resolve_expression(compiler.query)
     if hasattr(value, 'as_sql'):
         return compiler.compile(value)
     else:
         return self.get_db_prep_lookup(value, connection)
开发者ID:EmadMokhtar,项目名称:django,代码行数:13,代码来源:lookups.py

示例3: batch_process_rhs

 def batch_process_rhs(self, compiler, connection, rhs=None):
     if rhs is None:
         rhs = self.rhs
     if self.bilateral_transforms:
         sqls, sqls_params = [], []
         for p in rhs:
             value = Value(p, output_field=self.lhs.output_field)
             value = self.apply_bilateral_transforms(value)
             value = value.resolve_expression(compiler.query)
             sql, sql_params = compiler.compile(value)
             sqls.append(sql)
             sqls_params.extend(sql_params)
     else:
         _, params = self.get_db_prep_lookup(rhs, connection)
         sqls, sqls_params = ['%s'] * len(params), params
     return sqls, sqls_params
开发者ID:carlospalol,项目名称:django,代码行数:16,代码来源:lookups.py

示例4: process_rhs

 def process_rhs(self, compiler, connection):
     value = self.rhs
     if self.bilateral_transforms:
         if self.rhs_is_direct_value():
             # Do not call get_db_prep_lookup here as the value will be
             # transformed before being used for lookup
             value = Value(value, output_field=self.lhs.output_field)
         value = self.apply_bilateral_transforms(value)
         value = value.resolve_expression(compiler.query)
     # Due to historical reasons there are a couple of different
     # ways to produce sql here. get_compiler is likely a Query
     # instance and as_sql just something with as_sql. Finally the value
     # can of course be just plain Python value.
     if hasattr(value, 'get_compiler'):
         value = value.get_compiler(connection=connection)
     if hasattr(value, 'as_sql'):
         sql, params = compiler.compile(value)
         return '(' + sql + ')', params
     else:
         return self.get_db_prep_lookup(value, connection)
开发者ID:CrazyChief,项目名称:django,代码行数:20,代码来源:lookups.py

示例5:

from copy import copy
开发者ID:letouriste001,项目名称:SmartForest_2.0,代码行数:1,代码来源:lookups.py


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