logo
logo-hover
Menu

Description

The "thx-core" package provides a series of abstract mixins designed to simplify and standardize the creation of models in Django. These mixins offer common functionalities such as managing creator and last_modifier users, tracking creation and last modification dates, handling state, sorting records, and useful features for SEO optimization. Additionally, there are mixins available for data cleaning before saving, managing associated files, and obfuscating sensitive data.

Documentation

The "thx-core" package for Django offers a series of abstract mixins designed to simplify and enhance model management within applications. Each mixin has been developed with the goal of providing additional functionality to models, allowing developers to focus on building quality applications without having to reimplement the same logic repeatedly.

These mixins provide a wide range of functionalities, making data management within the application more streamlined and efficient. For example, the UserModel mixin automatically adds creator and last_modifier attributes to each model, enabling tracking of who created and modified a record in the database.

Another provided functionality is the DateModel mixin, which introduces the date_create and date_last_modify attributes, significantly simplifying the management of temporal information associated with each record.

The StatusModel mixin, on the other hand, adds a status attribute to indicate the current state of the record, which can be useful for implementing logical deletion of records or managing other custom states.

To establish a default order within a dataset, the OrderedModel mixin can be used, providing the ordering attribute to consistently organize records.

For optimizing your model for SEO, the SEOModel mixin provides a series of attributes such as meta_description, meta_keywords, and page_title, facilitating the website's visibility on search engines.

During the model's lifecycle, the CleanModel mixin redefines the save() method to ensure data validity before saving it to the database.

Finally, to manage the deletion of files associated with models, the DeleteFileModel mixin offers an implementation of the save() and delete() methods to ensure proper file cleanup when a record is deleted.

Model structure

The provided models include:

  • UserModel: to manage the creator and modifier users.
  • DateModel: to keep track of creation and last modification dates.
  • StatusModel: to handle the record's status.
  • OrderedModel: to establish a custom order in the queryset.
  • SEOModel: to optimize the model for SEO.
  • CleanModel: to perform data validation before saving.
  • DeleteFileModel: to manage the deletion of associated files.
  • ObfuscateModel: to obfuscate sensitive data.

 

Each model provides specific functionalities and can be used as a basis for defining custom models within a Django application.

Authors and contributors