Models#

Contains classes and methods for managing Django Models and their schedulers.

class fma_django.models.Client(*args, **kwargs)#

Bases: Model

Class for managing a Client’s UUID field.

uuid#

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

exception DoesNotExist#

Bases: ObjectDoesNotExist

args#
silent_variable_failure = True#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

aggregate_scores#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

classmethod check(**kwargs)#
clean()#

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clean_fields(exclude=None)#

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

clients_of_model#

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

date_error_message(lookup_type, field_name, unique_for)#
delete(using=None, keep_parents=False)#
classmethod from_db(db, field_names, values)#
full_clean(exclude=None, validate_unique=True, validate_constraints=True)#

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

get_constraints()#
get_deferred_fields()#

Return a set containing names of deferred fields for this instance.

model_updates#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>#
property pk#
prepare_database_save(field)#
refresh_from_db(using=None, fields=None)#

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

save(force_insert=False, force_update=False, using=None, update_fields=None)#

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)#

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

serializable_value(field_name)#

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

unique_error_message(model_class, unique_check)#
validate_constraints(exclude=None)#
validate_unique(exclude=None)#

Check unique constraints on the model and raise ValidationError if any failed.

class fma_django.models.DisplayClient(*args, **kwargs)#

Bases: Client

Allows the admin panel to show clients under the auth tab.

exception DoesNotExist#

Bases: DoesNotExist

args#
silent_variable_failure = True#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

aggregate_scores#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

classmethod check(**kwargs)#
clean()#

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clean_fields(exclude=None)#

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

clients_of_model#

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

date_error_message(lookup_type, field_name, unique_for)#
delete(using=None, keep_parents=False)#
classmethod from_db(db, field_names, values)#
full_clean(exclude=None, validate_unique=True, validate_constraints=True)#

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

get_constraints()#
get_deferred_fields()#

Return a set containing names of deferred fields for this instance.

model_updates#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>#
property pk#
prepare_database_save(field)#
refresh_from_db(using=None, fields=None)#

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

save(force_insert=False, force_update=False, using=None, update_fields=None)#

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)#

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

serializable_value(field_name)#

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

unique_error_message(model_class, unique_check)#
uuid#

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

validate_constraints(exclude=None)#
validate_unique(exclude=None)#

Check unique constraints on the model and raise ValidationError if any failed.

class fma_django.models.ClientUser(client)#

Bases: AnonymousUser

Class for authenticated Client Users.

property is_authenticated#

Property method for checking authentication.

Returns:

True

Return type:

bool

check_password(raw_password)#
delete()#
get_all_permissions(obj=None)#
get_group_permissions(obj=None)#
get_user_permissions(obj=None)#
get_username()#
property groups#
has_module_perms(module)#
has_perm(perm, obj=None)#
has_perms(perm_list, obj=None)#
id = None#
is_active = False#
property is_anonymous#
is_staff = False#
is_superuser = False#
pk = None#
save()#
set_password(raw_password)#
property user_permissions#
username = ''#
class fma_django.models.FederatedModel(*args, **kwargs)#

Bases: Model

Class for managing the fields for a Federated Model.

name#

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

developer#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

clients#

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

current_artifact#

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

aggregator#

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

requirement#

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

requirement_args#

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

update_schema#

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

client_agg_results_schema#

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

scheduler#

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

furthest_base_agg#

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

created_on#

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

last_modified#

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

property allow_aggregation#

Validates whether the model’s aggregation is paused or not.

Returns:

The status of allow_aggregation flag (True or False).

Return type:

bool

exception DoesNotExist#

Bases: ObjectDoesNotExist

args#
silent_variable_failure = True#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

aggregates#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

artifacts#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

classmethod check(**kwargs)#
clean()#

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clean_fields(exclude=None)#

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

current_artifact_id#
date_error_message(lookup_type, field_name, unique_for)#
delete(using=None, keep_parents=False)#
developer_id#
classmethod from_db(db, field_names, values)#
full_clean(exclude=None, validate_unique=True, validate_constraints=True)#

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

get_constraints()#
get_deferred_fields()#

Return a set containing names of deferred fields for this instance.

get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)#
get_next_by_last_modified(*, field=<django.db.models.fields.DateTimeField: last_modified>, is_next=True, **kwargs)#
get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)#
get_previous_by_last_modified(*, field=<django.db.models.fields.DateTimeField: last_modified>, is_next=False, **kwargs)#
id#

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

model_updates#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>#
property pk#
prepare_database_save(field)#
refresh_from_db(using=None, fields=None)#

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

save(force_insert=False, force_update=False, using=None, update_fields=None)#

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)#

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

scheduler_id#
serializable_value(field_name)#

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

unique_error_message(model_class, unique_check)#
validate_constraints(exclude=None)#
validate_unique(exclude=None)#

Check unique constraints on the model and raise ValidationError if any failed.

fma_django.models.create_model_aggregation_schedule_local(sender, instance, created, **kwargs)#

Create scheduler for every new Federated Model Aggregation.

Parameters:
  • sender (Any) – The id of the user requesting to create an aggregation task.

  • instance (Any) – An instance of a model object with aggregation tasks

  • created (Any) – A flag indicating if the task was already created.

  • kwargs (Dict, optional) – keyword arguments

fma_django.models.create_model_aggregation_schedule_remote(sender, instance, created, **kwargs)#

Create rule for lambda aggregation task for model.

Parameters:
  • sender (Any) – The id of the user requesting to create an aggregation task.

  • instance (Any) – An instance of a model object with an aggregation task.

  • created (Any) – A flag indicating if the task is already created

  • kwargs (Dict, optional) – keyword arguments

fma_django.models.delete_model_aggregation_schedule_local(sender, instance, **kwargs)#

When a model is deleted, deletes its scheduler.

Parameters:
  • sender (Any) – The id of the user requesting to delete an aggregation task.

  • instance (Any) – An instance of a model object with an aggregation task.

  • kwargs (Dict, optional) – keyword arguments

fma_django.models.delete_model_aggregation_schedule_remote(sender, instance, **kwargs)#

Create rule for lambda aggregation task for model.

Parameters:
  • sender (Any) – The id of the user requesting to delete an aggregation task.

  • instance (Any) – An instance of a model object with an aggregation task.

  • kwargs (Dict, optional) – keyword arguments

fma_django.models.get_aws_event_rule_state(federated_model)#

Checks the AWS Event Rule state for a given Federated Model.

Parameters:

federated_model (An instance of a model object with an aggregation task.) – federated model instance

Returns:

state of the rule associated with the aggregation task (disabled|enabled)

Return type:

(None|string)

fma_django.models.create_model_agg_task(*args, **kwargs)#

Creates tasks in the model aggregation scheduler.

Parameters:
  • args (Dict, optional) – arguments

  • kwargs (Dict, optional) – keyword arguments

fma_django.models.delete_model_agg_task(*args, **kwargs)#

Deletes tasks in the model aggregation scheduler.

Parameters:
  • args (Dict, optional) – arguments

  • kwargs (Dict, optional) – keyword arguments

class fma_django.models.ModelArtifact(*args, **kwargs)#

Bases: Model

Class for managing the fields of a Model Artifact.

values#

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
federated_model#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

version#

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

created_on#

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

exception DoesNotExist#

Bases: ObjectDoesNotExist

args#
silent_variable_failure = True#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

classmethod check(**kwargs)#
clean()#

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clean_fields(exclude=None)#

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

date_error_message(lookup_type, field_name, unique_for)#
delete(using=None, keep_parents=False)#
federated_model_id#
classmethod from_db(db, field_names, values)#
full_clean(exclude=None, validate_unique=True, validate_constraints=True)#

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

get_constraints()#
get_deferred_fields()#

Return a set containing names of deferred fields for this instance.

get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)#
get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)#
id#

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

objects = <django.db.models.manager.Manager object>#
property pk#
prepare_database_save(field)#
refresh_from_db(using=None, fields=None)#

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

save(force_insert=False, force_update=False, using=None, update_fields=None)#

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)#

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

serializable_value(field_name)#

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

unique_error_message(model_class, unique_check)#
validate_constraints(exclude=None)#
validate_unique(exclude=None)#

Check unique constraints on the model and raise ValidationError if any failed.

class fma_django.models.ModelAggregate(*args, **kwargs)#

Bases: MPTTModel

Class for managing the fields of a Model Aggregate.

federated_model#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

parent#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

result#

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
validation_score#

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

created_on#

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

exception DoesNotExist#

Bases: ObjectDoesNotExist

args#
silent_variable_failure = True#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class Meta#

Bases: object

abstract = False#
exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

classmethod check(**kwargs)#
children#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

clean()#

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clean_fields(exclude=None)#

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

client_scores#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

date_error_message(lookup_type, field_name, unique_for)#
delete(*args, **kwargs)#

Calling delete on a node will delete it as well as its full subtree, as opposed to reattaching all the subnodes to its parent node.

There are no argument specific to a MPTT model, all the arguments will be passed directly to the django’s Model.delete.

delete will not return anything.

federated_model_id#
classmethod from_db(db, field_names, values)#
full_clean(exclude=None, validate_unique=True, validate_constraints=True)#

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

get_ancestors(ascending=False, include_self=False)#

Creates a QuerySet containing the ancestors of this model instance.

This defaults to being in descending order (root ancestor first, immediate parent last); passing True for the ascending argument will reverse the ordering (immediate parent first, root ancestor last).

If include_self is True, the QuerySet will also include this model instance.

get_children()#

Returns a QuerySet containing the immediate children of this model instance, in tree order.

The benefit of using this method over the reverse relation provided by the ORM to the instance’s children is that a database query can be avoided in the case where the instance is a leaf node (it has no children).

If called from a template where the tree has been walked by the cache_tree_children filter, no database query is required.

get_constraints()#
get_deferred_fields()#

Return a set containing names of deferred fields for this instance.

get_descendant_count()#

Returns the number of descendants this model instance has.

get_descendants(include_self=False)#

Creates a QuerySet containing descendants of this model instance, in tree order.

If include_self is True, the QuerySet will also include this model instance.

get_family()#

Returns a QuerySet containing the ancestors, the model itself and the descendants, in tree order.

get_leafnodes(include_self=False)#

Creates a QuerySet containing leafnodes of this model instance, in tree order.

If include_self is True, the QuerySet will also include this model instance (if it is a leaf node)

get_level()#

Returns the level of this node (distance from root)

get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)#
get_next_sibling(*filter_args, **filter_kwargs)#

Returns this model instance’s next sibling in the tree, or None if it doesn’t have a next sibling.

get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)#
get_previous_sibling(*filter_args, **filter_kwargs)#

Returns this model instance’s previous sibling in the tree, or None if it doesn’t have a previous sibling.

get_root()#

Returns the root node of this model instance’s tree.

get_siblings(include_self=False)#

Creates a QuerySet containing siblings of this model instance. Root nodes are considered to be siblings of other root nodes.

If include_self is True, the QuerySet will also include this model instance.

id#

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

insert_at(target, position='first-child', save=False, allow_existing_pk=False, refresh_target=True)#

Convenience method for calling TreeManager.insert_node with this model instance.

is_ancestor_of(other, include_self=False)#

Returns True if this model is an ancestor of the given node, False otherwise. If include_self is True, also returns True if the two nodes are the same node.

is_child_node()#

Returns True if this model instance is a child node, False otherwise.

is_descendant_of(other, include_self=False)#

Returns True if this model is a descendant of the given node, False otherwise. If include_self is True, also returns True if the two nodes are the same node.

is_leaf_node()#

Returns True if this model instance is a leaf node (it has no children), False otherwise.

is_root_node()#

Returns True if this model instance is a root node, False otherwise.

level#

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

lft#

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

move_to(target, position='first-child')#

Convenience method for calling TreeManager.move_node with this model instance.

NOTE: This is a low-level method; it does NOT respect MPTTMeta.order_insertion_by. In most cases you should just move the node yourself by setting node.parent.

objects = <mptt.managers.TreeManager object>#
parent_id#
property pk#
prepare_database_save(field)#
refresh_from_db(using=None, fields=None)#

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

rght#

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

save(*args, **kwargs)#

If this is a new node, sets tree fields up before it is inserted into the database, making room in the tree structure as necessary, defaulting to making the new node the last child of its parent.

It the node’s left and right edge indicators already been set, we take this as indication that the node has already been set up for insertion, so its tree fields are left untouched.

If this is an existing node and its parent has been changed, performs reparenting in the tree structure, defaulting to making the node the last child of its new parent.

In either case, if the node’s class has its order_insertion_by tree option set, the node will be inserted or moved to the appropriate position to maintain ordering by the specified field.

save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)#

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

serializable_value(field_name)#

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

tree_id#

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

unique_error_message(model_class, unique_check)#
updates_used_to_agg#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

updates_using_this#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

validate_constraints(exclude=None)#
validate_unique(exclude=None)#

Check unique constraints on the model and raise ValidationError if any failed.

class fma_django.models.ModelUpdate(*args, **kwargs)#

Bases: Model

Class for managing the fields of a Model Update.

class TaskStatus(value)#

Bases: IntegerChoices

An enumeration.

PENDING = 0#
RUNNING = 1#
COMPLETE = 2#
FAILED = 3#
INVALID = 4#
client#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

federated_model#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

data#

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
status#

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

base_aggregate#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

applied_aggregate#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

created_on#

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

exception DoesNotExist#

Bases: ObjectDoesNotExist

args#
silent_variable_failure = True#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

applied_aggregate_id#
base_aggregate_id#
classmethod check(**kwargs)#
clean()#

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clean_fields(exclude=None)#

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

client_id#
date_error_message(lookup_type, field_name, unique_for)#
delete(using=None, keep_parents=False)#
federated_model_id#
classmethod from_db(db, field_names, values)#
full_clean(exclude=None, validate_unique=True, validate_constraints=True)#

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

get_constraints()#
get_deferred_fields()#

Return a set containing names of deferred fields for this instance.

get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)#
get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)#
get_status_display(*, field=<django.db.models.fields.IntegerField: status>)#
id#

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

objects = <django.db.models.manager.Manager object>#
property pk#
prepare_database_save(field)#
refresh_from_db(using=None, fields=None)#

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

save(force_insert=False, force_update=False, using=None, update_fields=None)#

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)#

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

serializable_value(field_name)#

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

unique_error_message(model_class, unique_check)#
validate_constraints(exclude=None)#
validate_unique(exclude=None)#

Check unique constraints on the model and raise ValidationError if any failed.

class fma_django.models.ClientAggregateScore(*args, **kwargs)#

Bases: Model

Class for managing the fields of a Client Aggregate Score.

aggregate#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

client#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

validation_results#

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

created_on#

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

exception DoesNotExist#

Bases: ObjectDoesNotExist

args#
silent_variable_failure = True#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

aggregate_id#
classmethod check(**kwargs)#
clean()#

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clean_fields(exclude=None)#

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

client_id#
date_error_message(lookup_type, field_name, unique_for)#
delete(using=None, keep_parents=False)#
classmethod from_db(db, field_names, values)#
full_clean(exclude=None, validate_unique=True, validate_constraints=True)#

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

get_constraints()#
get_deferred_fields()#

Return a set containing names of deferred fields for this instance.

get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)#
get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)#
id#

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

objects = <django.db.models.manager.Manager object>#
property pk#
prepare_database_save(field)#
refresh_from_db(using=None, fields=None)#

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

save(force_insert=False, force_update=False, using=None, update_fields=None)#

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)#

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

serializable_value(field_name)#

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

unique_error_message(model_class, unique_check)#
validate_constraints(exclude=None)#
validate_unique(exclude=None)#

Check unique constraints on the model and raise ValidationError if any failed.