DateTime Field

Table of contents

  1. Example Usage
  2. Allowed Attributes
    1. Default
    2. Required
    3. Column Name
    4. Validator
    5. Auto
    6. Auto Update (v2.0.0)
    7. Example Usage

Example Usage

class User(Model):
    created = DateTime()


u = User()
u.created = datetime.datetime.now()

Allowed Attributes

The following attributes supported by DateTime Field.

  1. default
  2. required
  3. column_name
  4. validator
  5. auto
  • Default

    Default value for field. This is base attribute that is available in all fields. Read More

  • Required

    Set True if value is required for the field. This is base attribute that is available in all fields. Read More

  • Column Name

    Set different column name in Firestore instead of field name. This is base attribute that is available in all fields. Read More

  • Validator

    Validate given value of field. This is base attribute that is available in all fields Read More

  • Auto

    Set the auto date if no value is provided

  • Auto Update (v2.0.0)

    Set firestore.SERVER_TIMESTAMP on every create or update operation

Example Usage

class User(Model):
    created = DateTime(auto=True)


u = User()
u.save()
print(u.created)

Copyright © 2019 FireO All rights reserved. Powered by OctaByte