common package

Submodules

common.base_model module

Healthy Meals Web Site Copyright (C) 2025 David A. Taylor of Taylored Web Sites (tayloredwebsites.com) Licensed under AGPL-3.0-only. See https://opensource.org/license/agpl-v3/

https://github.com/tayloredwebsites/healthy-meals - healthy_meals/base_model.py

class common.base_model.BaseModel(*args, **kwargs)[source]

Bases: SafeDeleteModel

Database table: None

BaseModel is abstract class to base all models in this project

SOFT DELETE FUNCTIONALITY Note: The customized functions for soft deletion are only found in model manager classes Thus??: to use the methods found in ‘objects’, their models must declare their custom manager based off of SafeDeleteManager (This should be validated!!!) See: accounts/models.py for an example

AUDITLOG VERSIONING HISTORY FUNCTIONALITY - has record history / versioning through django-auditlog (https://github.com/jazzband/django-auditlog)

Note: To register auditlog to automatically log all changes to a model, it must be registered in the model To register auditlog, the last line of the model should have the auditlog.register statement. For Example (as can be seen in accounts/models.py):

auditlog.register(CustomUser, exclude_fields=[

‘password’, # protect this field for security reasons ‘last_login’, # do not update audit log for each login ]

Parameters:

Relationship fields:

Parameters:

history (AuditlogHistoryField to LogEntry) – History

created_at

Type: DateTimeField

Created at

A wrapper for a deferred-loading field. When the value is read from this

deleted

Type: DateTimeField

Deleted

A wrapper for a deferred-loading field. When the value is read from this

deleted_by_cascade

Type: BooleanField

Deleted by cascade

A wrapper for a deferred-loading field. When the value is read from this

get_next_by_created_at(*, field=<django.db.models.DateTimeField: created_at>, is_next=True, **kwargs)

Finds next instance based on created_at. See get_next_by_FOO() for more information.

get_next_by_updated_at(*, field=<django.db.models.DateTimeField: updated_at>, is_next=True, **kwargs)

Finds next instance based on updated_at. See get_next_by_FOO() for more information.

get_previous_by_created_at(*, field=<django.db.models.DateTimeField: created_at>, is_next=False, **kwargs)

Finds previous instance based on created_at. See get_previous_by_FOO() for more information.

get_previous_by_updated_at(*, field=<django.db.models.DateTimeField: updated_at>, is_next=False, **kwargs)

Finds previous instance based on updated_at. See get_previous_by_FOO() for more information.

history

Type: Reverse AuditlogHistoryField from BaseModel

All + of this log entry

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example:

class Post(Model):
    comments = GenericRelation(Comment)
rec_history_count()[source]

Return the count of all of the history records for this user.

rec_history_field_changed(user_rec, field_name)[source]

Return the number of records that are maintained in CustomUser’s history table.

rec_history_field_is_now(user_rec, field_name)[source]

Return the latest history record value for this field (should be identical to current field value)

rec_history_field_was(user_rec, field_name)[source]

Return a dictionary of the previous values for this field, for this record.

updated_at

Type: DateTimeField

Updated at

A wrapper for a deferred-loading field. When the value is read from this

Module contents