本文整理匯總了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)