The API of djeneralize is broken down into five modules:
Customized manager to ensure that any QuerySet that is used always returns specialized model instances rather than generalized model instances.
The manager can either return final_specializations, i.e. the most specialized specialization, or the direct specialization of the general model.
Set the _final_specialization attribute on a clone of the queryset to ensure only directly descended specializations are considered.
| Returns: | The cloned queryset |
|---|---|
| Return type: | SpecializedQuerySet |
Set the _final_specialization attribute on a clone of the queryset to ensure only terminal specializations are considered.
| Returns: | The cloned queryset |
|---|---|
| Return type: | SpecializedQuerySet |
Instead of returning a QuerySet, use SpecializedQuerySet instead
| Returns: | A specialized queryset |
|---|---|
| Return type: | SpecializedQuerySet |
The metaclass for BaseGeneralizedModel
Base model from which all Generalized and Specialized models inherit
Get the specialized model instance which corresponds to the general case.
| Parameters: | final_specialization (bool) – Whether the specialization returned is the most specialized specialization or whether the direct specialization is used |
|---|---|
| Returns: | The specialized model corresponding to the current model |
Set the specialization_type of this instance to match that specified by its specialization in the inner class Meta.
Field to store the specialization
Ensure that a BaseGeneralizationModel subclass contains a default specialization manager and sets the _default_specialization_manager attribute on the class.
| Parameters: | sender (django.db.models.base.Model) – The class which emitted the class prepared signal which needs to be checked for the specialization manager |
|---|
A wrapper around QuerySet to ensure specialized models are returned.
Set the _final_specialization attribute on a clone of this queryset to ensure only directly descended specializations are considered.
| Returns: | The cloned queryset |
|---|---|
| Return type: | SpecializedQuerySet |
Set the _final_specialization attribute on a clone of this queryset to ensure only terminal specializations are considered.
| Returns: | The cloned queryset |
|---|---|
| Return type: | SpecializedQuerySet |
Override get to ensure a specialized model instance is returned.
| Returns: | A specialized model instance |
|---|
Override the iteration to ensure what’s returned are Specialized Model instances.
Utilities for djeneralize
Manipulate path_to_reduce so that it only contains one more level of detail than current_path.
| Parameters: |
|
|---|---|
| Returns: | The path one level deeper than that of current_path |
| Return type: | unicode |