autowisp.browser_interface.core.models module

Class Inheritance Diagram

Inheritance diagram of BuiModelBase

Shared base class for the browser interface’s database models.

class autowisp.browser_interface.core.models.BuiModelBase(*args, **kwargs)[source]

Bases: Model

Inheritance diagram of autowisp.browser_interface.core.models.BuiModelBase

Base for browser-interface models, recording when each row changed.

Every model in the browser-interface database should derive from this, so that a row can always be placed in time when something needs unpicking after the fact. It is the counterpart of the project database’s autowisp.database.data_model.base.DataModelSubBase, which carries the same information in a column named timestamp.

auto_now alone would not be enough to keep modified honest. It fires on Model.save() and bulk_create(), but not on QuerySet.update(), bulk_update() or raw SQL – and bulk_update is worse than a simple omission, since it reads the in-memory value rather than calling pre_save and so writes back whatever was loaded, preserving a stale timestamp. A database trigger covers what auto_now cannot; see autowisp.browser_interface.core.timestamp_triggers. Both are kept: the trigger is the guarantee, auto_now is what leaves the in-memory object correct after a save() without re-reading it.

class Meta[source]

Bases: object

Contribute the fields to subclasses without creating a table.

abstract = False
created

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)
get_next_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=True, **kwargs)
get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)
get_previous_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=False, **kwargs)
modified

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.