Skip to content
Discussion options

You must be logged in to vote

I figured it out - apparently you just have to reference the object in there which is different than how the API shows it. The API shows it requiring both fields as I had this written originally.

Working code:

def run(self, data, commit):

        primary_ge1 = Interface.objects.get(device_id=13055, name="GE1")
        ha_ge1 = Interface.objects.get(device_id=13056, name="GE1")

        new_cable = Cable(
                a_terminations=[ primary_ge1 ],
                b_terminations=[ ha_ge1  ]
                )

        new_cable.save()
        self.log_success(f"Created new cable {new_cable}")

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cslingerland
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant