Question

I wrote an dexterity type with a field relating to another object:

institution = RelationChoice(
    title=_(u"Institution"),
    source=ObjPathSourceBinder(
        object_provides=IInstitution.__identifier__
    ),
)

And also in the template I wrote:

<span id="institution" tal:content="context/institution" />

But it prints:

<z3c.relationfield.relation.RelationValue object at 0xe3a032c>

I have tried to get attributes to build a link to the item, but the next doesn't works:

<span id="institution" tal:content="context/institution/absolute_url" />

How can I get the attributes of the objecto to make a link to it?

Was it helpful?

Solution

Reference objects are documented in the Dexterity developer manual. You are looking for the to_object attribute:

<span id="institution" tal:content="context/institution/to_object/absolute_url" />

which would insert the URL of the linked object, or you could show the Title instead:

<span id="institution" tal:content="context/institution/to_object/Title" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top