From 608f96c72329cf26f9ef9e1c8a805808502c069a Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 26 Apr 2023 23:18:03 +1000 Subject: [PATCH] Add python example for deleting a part (#4703) * Add python example for deleting a part * Ignore PRs which are just docs from release notes --- .github/release.yml | 1 + docs/docs/api/python/examples.md | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/.github/release.yml b/.github/release.yml index 34562cd9b7..3bba14b063 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -4,6 +4,7 @@ changelog: exclude: labels: - translation + - documentation categories: - title: Breaking Changes labels: diff --git a/docs/docs/api/python/examples.md b/docs/docs/api/python/examples.md index cbe4a7b32c..a02a891a03 100644 --- a/docs/docs/api/python/examples.md +++ b/docs/docs/api/python/examples.md @@ -188,6 +188,18 @@ loc = StockLocation(api, pk=12) item.transferStock(loc, quantity=50) ``` +### Delete a Part + +To delete a [Part instance](../../part/part.md), first in needs to be marked as *inactive* (otherwise it will throw an error): + +```python +from inventree.part import Part + +part = Part(api, pk=10) +part.save(data={'active': False}) +part.delete() +``` + ### Bulk Delete Some database models support bulk delete operations, where multiple database entries can be deleted in a single API query.