Closed martonmiklos closed 1 year ago
@martonmiklos something strange going on here.
Firstly, the PartCategory
API endpoint does not let you filter by category name. You could search for the category using `search='Arena cikkek' though.
What version of inventree-python
library are you running? I ran a test on 0.8.3
(with latest master inventree server):
from inventree.api import InvenTreeAPI
from inventree.part import PartCategory
api = InvenTreeAPI('http://localhost:8000', username='admin', password='inventree')
cats = PartCategory.list(api, name='Electronics')
for cat in cats:
print(cat.pk, cat.name)
output:
1 Electronics
13 Connectors
21 Pin Headers
8 IC
9 Interface
11 MCU
4 Passives
6 Capacitors
7 Inductors
5 Resistors
And the server logs:
[20/Oct/2022 04:54:49] "GET /api/part/category/?name=Electronics HTTP/1.1" 200 5802
So, note that the pk
value is not getting included in the API query, like it is in your case.
@SchrodingersGat Many thanks for your response!
Firstly, the PartCategory API endpoint does not let you filter by category name.
Is it intentional? I think searching category by name is a valid demand in the case if someone tries to create migration tools. If not intentional I can look into fixing this, however if you can pinpoint where should I look that would be awesome.
You could search for the category using `search='Arena cikkek' though.
Yeah it helped me, however it search in a wildcarded way (searching for 'Cable' list 'Cable assemblies' as well which needs post filtering for identical match).
If not intentional I can look into fixing this
You can create a PR over on the inventree source.
You will need to add 'name' the 'filterset_fields' list:
Hello folks,
I am running InvenTree stable. I have tried to serch for a category with:
identical = PartCategory.list(api, name='Arena cikkek')
And it returns an unfilteted list:The name parameter seems to be going out in the request parameter:
[19/Oct/2022 14:43:58] "GET /api/part/category/?pk=1 HTTP/1.1" 200 732
With the InvenTree's built in API tester I can filter according to my desire:
Am I missing something at the API usage?