View source on GitHub
|
A date property, which stores a date without a time.
Inherits From: DateTimeProperty, Property, expected_type
google.appengine.ext.db.DateProperty(
verbose_name=None, auto_now=False, auto_now_add=False, **kwds
)
Args | |
|---|---|
verbose_name
|
Verbose name is always first parameter. |
auto_now
|
Date/time property is updated with the current time every time it is saved to the datastore. Useful for properties that want to track the modification time of an instance. |
auto_now_add
|
Date/time is set to the when its instance is created. Useful for properties that record the creation time of an entity. |
Child Classes
Methods
datastore_type
datastore_type()
Deprecated backwards-compatible accessor method for self.data_type.
default_value
default_value()
Default value for datetime.
| Returns | |
|---|---|
value of now() as appropriate to the date-time instance if auto_now
or auto_now_add is set, else user configured default value
implementation.
|
empty
empty(
value
)
Determine if value is empty in the context of this property.
For most kinds, this is equivalent to "not value", but for kinds like
bool, the test is more subtle, so subclasses can override this method
if necessary.
| Args | |
|---|---|
value
|
Value to validate against this Property.
|
| Returns | |
|---|---|
True if this value is considered empty in the context of this Property
type, otherwise False.
|
get_updated_value_for_datastore
get_updated_value_for_datastore(
model_instance
)
Get new value for property to send to datastore.
| Returns | |
|---|---|
now() as appropriate to the date instance in the odd case where
auto_now is set to True, else AUTO_UPDATE_UNCHANGED.
|
get_value_for_datastore
get_value_for_datastore(
model_instance
)
Get value from property to send to datastore.
We retrieve a datetime.date from the model instance and return a
datetime.datetime instance with the time set to zero.
See base class method documentation for details.
make_value_from_datastore
make_value_from_datastore(
value
)
Native representation of this property.
We receive a datetime.datetime retrieved from the entity and return
a datetime.date instance representing its date portion.
See base class method documentation for details.
make_value_from_datastore_index_value
make_value_from_datastore_index_value(
index_value
)
now
@staticmethodnow()
Get now as a date datetime value.
| Returns | |
|---|---|
| 'date' part of 'now' only. |
validate
validate(
value
)
Validate date.
| Returns | |
|---|---|
| A valid value. |
| Raises | |
|---|---|
BadValueError if property is not instance of 'date',
or if it is an instance of 'datetime' (which is a subclass
of 'date', but for all practical purposes a different type).
|
Class Variables | |
|---|---|
| creation_counter |
2
|
View source on GitHub