Skip to main content
Answer

Pygen Error "Direct relation without source does not have a linked class" when trying to define a MultiReverseDirectRelationApply in a View.

  • November 19, 2025
  • 2 replies
  • 18 views

Forum|alt.badge.img+1

Hi, I have defined a Data Model with a Source View having a DirectRelation to a Target View as a simplified version below, which Pygen created an SDK successfully.  But when I added a ReverseDirectRelationApply to the Target View, Pygen returned the captioned error.  Please help.

source_container = ContainerApply(

       space =”myspace”,

       external_id=”sourceContainer”,

       properties={

            “sourceName”: ContainerProperty(type=Text, name=”sourceName”),

            “target”: ContainerProperty(type=DirectRelation(is_list=False, container=ContainerId(space=”myspace”, external_id=”targetcontainer”) }

 

target_container = ContainerApply(

       space =”myspace”,

       external_id=”targetContainer”,

       properties={

            “targetName”: ContainerProperty(type=Text, name=”targetName”)}

 

source_view = ViewApply(

     space = “myspace”,

     external_id = “souceView”,

     version = “1.0”,

     properties = {

           “sourceName”: MappedPropertyApply(container=ContainerId(“myspace”, “sourceContainer”), container_property_identifier =”sourceName”),

           “target”: MappedPropertyApply(container=ContainerId(“myspace”, “sourceContainer”), container_property_identifier =”target”), source = ViewId(“myspace”, “targetView”, “1.0”) ) }

 

target_view = ViewApply(

     space = “myspace”,

     external_id = “targetView”,

     version = “1.0”,

     properties = {

           “targetName”: MappedPropertyApply(container=ContainerId(“myspace”, “targetContainer”), container_property_identifier =”targetName”),

           “sources”: MultiReverseDirectRelationApply(source =ViewId(“myspace”,”sourceView”, “1.0”),

                            through=PropertyId(ViewId(space=”myspace”, external_id=”sourceView”, version=”1.0”, “target”), name = “sources”))} )

      

Best answer by Anders Albert

I might be missing some information here, but I don't see an error in your message just definitions of containers and views.

 

Note reveres direct relations are not set, they are inferred based on the direct relations. So in pygen, you will only get the reveres direct relation on the read object, not the write object.

2 replies

Anders  Albert
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • Answer
  • November 19, 2025

I might be missing some information here, but I don't see an error in your message just definitions of containers and views.

 

Note reveres direct relations are not set, they are inferred based on the direct relations. So in pygen, you will only get the reveres direct relation on the read object, not the write object.


Forum|alt.badge.img+1

Thanks Anders, as soon as I replaced the ReverseDirectRelationApply with the read object and re-deployed the Data Model, Pygen can now generate the SDK without error. 👍