Accessing Custom Objects

TrialGrid allows Custom Objects to be defined as child objects of drafts. These can be accessed and included in Document Templates via the draft customobject_set attribute.

{% for custom_object in draft.customobject_set.all() %}
    {{custom_object.identifier}}
{% endfor %}

In the above example we list all the custom objects which belong to the draft. Normally we will be interested in one type of custom object. To get only custom objects of a certain type we can filter further:

{% for custom_object in draft.customobject_set.filter(custom_object_definition__name="Report Specification") %}
    {{custom_object.identifier}}
{% endfor %}

Some custom objects can have child objects. These can be accessed through the customobject_set of the parent object:

{% for custom_object in draft.customobject_set.filter(custom_object_definition__name="Report Specification") %}
    {{custom_object.identifier}}
    {% for child_object in custom_object.customobject_set.filter(custom_object_definition__name="Report Column") %}
      Child ->{{child_object.identifier}}
    {% endfor %}
{% endfor %}