當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。