本文整理汇总了Python中google.appengine.ext.db.DateTimeProperty方法的典型用法代码示例。如果您正苦于以下问题:Python db.DateTimeProperty方法的具体用法?Python db.DateTimeProperty怎么用?Python db.DateTimeProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.appengine.ext.db
的用法示例。
在下文中一共展示了db.DateTimeProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _decode_bookmark
# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import DateTimeProperty [as 别名]
def _decode_bookmark(self, bookmark):
"""Decodes a bookmark and prepares the values to be used on queries.
Currently supported properties are DateTimeProperty, FloatProperty,
IntegerProperty, StringProperty and ReferenceProperty.
Returns:
A dictionary of property names/values to be used in queries.
"""
required = list(self._bookmark_properties)
required.append('_')
try:
bookmark = decode_bookmark(bookmark)
# Ensure that all required values are available.
for key in required:
if key not in bookmark:
return None
except:
return None
for key in required:
value = bookmark[key]
if key == '_':
self._first_result = bookmark[key]
elif key == '__key__':
bookmark[key] = db.Key(value)
else:
prop = getattr(self._model_class, key)
if isinstance(prop, db.ReferenceProperty):
bookmark[key] = db.Key(value)
elif isinstance(prop, db.DateTimeProperty):
bookmark[key] = parseDateTime(value)
else:
bookmark[key] = prop.data_type(value)
return bookmark
# from http://kbyanc.blogspot.com/2007/09/python-reconstructing-datetimes-from.html
示例2: convert_DateTimeProperty
# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import DateTimeProperty [as 别名]
def convert_DateTimeProperty(model, prop, kwargs):
"""Returns a form field for a ``db.DateTimeProperty``."""
if prop.auto_now or prop.auto_now_add:
return None
kwargs.setdefault('format', '%Y-%m-%d %H:%M:%S')
return f.DateTimeField(**kwargs)
示例3: get_form_field
# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import DateTimeProperty [as 别名]
def get_form_field(self, **kwargs):
"""Return a Django form field appropriate for a date-time property.
This defaults to a DateTimeField instance, except if auto_now or
auto_now_add is set, in which case None is returned, as such
'auto' fields should not be rendered as part of the form.
"""
if self.auto_now or self.auto_now_add:
return None
defaults = {'form_class': forms.DateTimeField}
defaults.update(kwargs)
return super(DateTimeProperty, self).get_form_field(**defaults)