Reference#

django_directed#

Initialize module.

admin.py#

Admin for the django_directed app.

apps.py#

App configuration for the django_directed app.

class django_directed.apps.DjangoDirectedConfig(app_name, app_module)#

config.py#

context_managers.py#

Context managers for the django_directed app.

django_directed.context_managers.get_current_graph_instance(graph_fullname)#

Returns the graph if it exists in the local thread.

django_directed.context_managers.graph_scope(graph)#

Context manager for graphs.

Used to set and cleanup Graph instance. If nested, saves outer context and resets it at conclusion of scope.

Parameters:

graph (BaseGraph) –

fields.py#

Custom model fields for Django Directed.

class django_directed.fields.CurrentGraphFKField(*args, **kwargs)#

A ForeignKey field that defaults to the current Graph instance.

deconstruct()#

Deconstructs the field.

pre_save(model_instance, add)#

Sets the value of the field on save.

forms.py#

Forms for django_directed.

manager_methods.py#

Manager methods for the django_directed app.

model_methods.py#

Model methods for django_directed.

models/abstract_base_graph_models.py#

Abstract Base Graph Models for Django Directed.

class django_directed.models.abstract_base_graph_models.BaseEdge(*args, **kwargs)#

Base Edge Model lets us verify that a given model instance derives from BaseEdge.

class django_directed.models.abstract_base_graph_models.BaseGraph(*args, **kwargs)#

Base Graph Model lets us verify that a given model instance derives from BaseGraph.

class django_directed.models.abstract_base_graph_models.BaseNode(*args, **kwargs)#

Base Node Model lets us verify that a given model instance derives from BaseNode.

django_directed.models.abstract_base_graph_models.base_edge(config)#

Creates “Abstract Edge Model”.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_base_graph_models.base_graph(config)#

Creates “Abstract Graph Model”.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_base_graph_models.base_node(config)#

Creates “Abstract Node Model”.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_base_graph_models.get_graph_aware_manager(config)#

Creates a manager that is aware of the current graph instance.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_base_graph_models.get_graph_aware_queryset(config)#

Creates a queryset that is aware of the current graph instance.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_base_graph_models.get_model_class(model_fullname)#

Provided with a model fullname (app_name.ModelName), returns the associated model class.

Parameters:

model_fullname (str) –

Return type:

Model

models/abstract_graph_models.py#

Abstract models for Django Directed.

django_directed.models.abstract_graph_models.arborescence_edge_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Edge base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.arborescence_graph_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Graph base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.arborescence_node_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Node base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.cyclic_edge_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Edge base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.cyclic_graph_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Graph base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.cyclic_node_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Node base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.dag_edge_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Edge base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.dag_graph_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Graph base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.dag_node_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Node base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.polytree_edge_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Edge base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.polytree_graph_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Graph base model are implemented.

Parameters:

config (GraphConfig) –

django_directed.models.abstract_graph_models.polytree_node_factory(config)#

Type: Subclassed Abstract Model. Abstract methods of the Node base model are implemented.

Parameters:

config (GraphConfig) –

models/model_factory.py#

Model factory for directed graph models.

class django_directed.models.model_factory.ArborescenceService(config)#

Returns the actual Graph, Edge, and Node models.

Parameters:

config (GraphConfig) –

edge()#

Returns the actual Edge model.

graph()#

Returns the actual Graph model.

node()#

Returns the actual Node model.

class django_directed.models.model_factory.CyclicService(config)#

Returns the actual Graph, Edge, and Node models.

Parameters:

config (GraphConfig) –

edge()#

Returns the actual Edge model.

graph()#

Returns the actual Graph model.

node()#

Returns the actual Node model.

class django_directed.models.model_factory.DAGService(config)#

Returns the actual Graph, Edge, and Node models.

Parameters:

config (GraphConfig) –

edge()#

Returns the actual Edge model.

graph()#

Returns the actual Graph model.

node()#

Returns the actual Node model.

class django_directed.models.model_factory.DirectedServiceFactory#

Registers django-directed services.

get(config, **kwargs)#

Creates and returns a new model factory for directed graph models.

Parameters:

config (GraphConfig) –

register(key, builder)#

Registers model factory services.

services_enum()#

Return enum of registered services.

services_list()#

Return list of registered services.

class django_directed.models.model_factory.PolytreeService(config)#

Returns the actual Graph, Edge, and Node models.

Parameters:

config (GraphConfig) –

edge()#

Returns the actual Edge model.

graph()#

Returns the actual Graph model.

node()#

Returns the actual Node model.

django_directed.models.model_factory.create_arborescence_service(config)#

Creates a new ArborescenceService instance.

Parameters:

config (GraphConfig) –

django_directed.models.model_factory.create_cyclic_service(config)#

Creates a new CyclicService instance.

Parameters:

config (GraphConfig) –

django_directed.models.model_factory.create_dag_service(config)#

Creates a new DAGService instance.

Parameters:

config (GraphConfig) –

django_directed.models.model_factory.create_polytree_service(config)#

Creates a new PolytreeService instance.

Parameters:

config (GraphConfig) –

query_utils.py#

Functions for transforming RawQuerySet or other outputs of django-directed to alternate formats.

django_directed.query_utils.check_field_list(obj)#

Verifies that obj is a list of strings.

Used with model_to_dict to ensure that the field_list argument is valid.

django_directed.query_utils.edges_from_nodes_queryset(nodes_queryset)#

Given an Edge Model and a QuerySet or RawQuerySet of nodes, returns a queryset of the associated edges.

django_directed.query_utils.get_field_value(instance, field, date_strf=None)#

Extracts the value of a field from a model instance.

Used with model_to_dict to extract the value of a field from a model instance.

django_directed.query_utils.get_instance_characteristics(instance)#

Returns a tuple of the node & edge model classes and the instance_type for the provided instance.

django_directed.query_utils.get_queryset_characteristics(queryset)#

Returns a tuple of the node & edge model classes and the queryset type for the provided queryset.

django_directed.query_utils.model_to_dict(instance, field_list, date_strf=None)#

Returns a dictionary of {field_name: field_value} for a given model instance.

e.g.: model_to_dict(myqueryset.first(), fields=[“id”,]) For DateTimeFields, a formatting string can be provided Adapted from: https://ziwon.github.io/post/using_custom_model_to_dict_in_django/

django_directed.query_utils.nodes_from_edges_queryset(edges_queryset)#

Given a Node Model and a QuerySet or RawQuerySet of edges, returns a queryset of the associated nodes.

queryset_methods.py#

QuerySet methods for the django_directed app.

signals.py#

Signals for django_directed.

validators.py#

Validators for the django_directed app.

views.py#

Views for the django_directed app.

urls.py#

Views for the django_directed app.