lamindb.base.fields.DateTimeField

class lamindb.base.fields.DateTimeField(*args, **kwargs)

Bases: DateTimeField

Custom DateTimeField with default values for blank.

Django default values for DateTimeField are blank=False.

Attributes

auto_creation_counter = -59
property choices
class_lookups = {'contained_by': <class 'django.contrib.postgres.fields.ranges.RangeContainedBy'>, 'date': <class 'django.db.models.functions.datetime.TruncDate'>, 'hour': <class 'django.db.models.functions.datetime.ExtractHour'>, 'minute': <class 'django.db.models.functions.datetime.ExtractMinute'>, 'second': <class 'django.db.models.functions.datetime.ExtractSecond'>, 'time': <class 'django.db.models.functions.datetime.TruncTime'>}
creation_counter = 964
property db_returning

Private API intended only to be used by Django itself.

property db_tablespace
default_error_messages = {'invalid': '“%(value)s” value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.', 'invalid_date': '“%(value)s” value has the correct format (YYYY-MM-DD) but it is an invalid date.', 'invalid_datetime': '“%(value)s” value has the correct format (YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]) but it is an invalid date/time.'}
default_validators = []
description = 'Date (with time)'
descriptor_class = <class 'django.db.models.query_utils.DeferredAttribute'>
empty_strings_allowed = False
empty_values = [None, '', [], (), {}]
property flatchoices

Flattened version of choices tuple.

generated = False
get_lookups = functools.partial(<functools._lru_cache_wrapper object>, <class 'lamindb.base.fields.DateTimeField'>)
hidden = False
many_to_many = None
many_to_one = None
non_db_attrs = ('blank', 'choices', 'db_column', 'editable', 'error_messages', 'help_text', 'limit_choices_to', 'on_delete', 'related_name', 'related_query_name', 'validators', 'verbose_name')
one_to_many = None
one_to_one = None
register_lookup = functools.partial(<function RegisterLookupMixin.register_class_lookup>, <class 'lamindb.base.fields.DateTimeField'>)
related_model = None
system_check_deprecated_details = None
system_check_removed_details = None

Class methods

classmethod get_class_lookups()
classmethod register_class_lookup(lookup, lookup_name=None)

Methods

cast_db_type(connection)

Return the data type to use in the Cast() function.

check(**kwargs)
clone()

Uses deconstruct() to clone a new copy of this Field. Will not preserve any class attachments/attribute names.

contribute_to_class(cls, name, **kwargs)
db_check(connection)

Return the database column check constraint for this field, for the provided connection. Works the same way as db_type() for the case that get_internal_type() does not map to a preexisting model field.

db_parameters(connection)

Extension of db_type(), providing a range of different return values (type, checks). This will look at db_type(), allowing custom model fields to override it.

db_type(connection)

Return the database column data type for this field, for the provided connection.

db_type_parameters(connection)
db_type_suffix(connection)
deconstruct()
formfield(**kwargs)
get_attname()
get_attname_column()
get_choices(include_blank=True, blank_choice=[('', '---------')], limit_choices_to=None, ordering=())

Return choices with a default blank choices included, for use as <select> choices for this field.

get_col(alias, output_field=None)
get_db_converters(connection)
get_db_prep_save(value, connection)

Return field’s value prepared for saving into a database.

get_db_prep_value(value, connection, prepared=False)
get_default()

Return the default value for this field.

get_filter_kwargs_for_object(obj)

Return a dict that when passed as kwargs to self.model.filter(), would yield all instances having the same value for this field as obj has.

get_instance_lookups()
get_internal_type()
get_lookup(lookup_name)
get_pk_value_on_save(instance)

Hook to generate new PK values on save. This method is called when saving instances with no primary key value set. If this method returns something else than None, then the returned value is used when saving the new instance.

get_prep_value(value)
get_transform(lookup_name)
has_default()

Return a boolean of whether this field has a default value.

pre_save(model_instance, add)
register_instance_lookup(lookup, lookup_name=None)
rel_db_type(connection)

Return the data type that a related field pointing to this field should use. For example, this method is called by ForeignKey and OneToOneField to determine its data type.

run_validators(value)
save_form_data(instance, data)
select_format(compiler, sql, params)

Custom format for select clauses. For example, GIS columns need to be selected as AsText(table.col) on MySQL as the table.col data can’t be used by Django.

set_attributes_from_name(name)
slice_expression(expression, start, length)

Return a slice of this field.

to_python(value)
validate(value, model_instance)

Validate value and raise ValidationError if necessary. Subclasses should override this to provide validation logic.

value_from_object(obj)

Return the value of this field in the given model instance.

value_to_string(obj)