Replies: 2 comments
|
I found this in someone else's code and will give it a tryout. |
0 replies
|
Yes — from inventree.part import Part
parts = Part.list(api, IPN='830-00017')
pk = parts[0].pk if parts else NoneThree things worth knowing before relying on it. I checked these against demo.inventree.org (API 530):
One note on the snippet you found in your follow-up post: |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi all,
Is there a simple method to obtain the primary key (pk) of a part based on the part's IPN.
So I have "830-00017" as the part.IPN and "My fancy controller" as the part.name and want returned the pk from the table, to be used in the next Python call; Eg a delete, or make-active or a BOM link.
Currently I am using a DICT based on all parts returned from my database.
This is OK for me, for now, but I'm sure there is a more succinct method. I simply cannot see it at the moment.
For those who are interested, here is my code:
All reactions