vitalik / django-ninja

💨 Fast, Async-ready, Openapi, type hints based framework for building APIs
https://django-ninja.dev
MIT License
7.15k stars 426 forks source link

Add fields lookup in url #374

Open Jocelyn-AGORO opened 2 years ago

Jocelyn-AGORO commented 2 years ago

Sometimes it could be helpful to have django fields lookup in the url as query params. It help make very cool things. example if I need to filter on a specific model, like user: http://localhost:8000/users?username__startswith=a or http://localhost:8000/users?username__startwiths=a&email__endswith=@gmail.com Or on order model supposing user has orders http://localhost:8000/orders?user__username=vitalik or http://localhost:8000/orders?user__username=vitalik&purchase__gte=2022-01-01

baseplate-admin commented 1 year ago

Hi https://github.com/vitalik/django-ninja/pull/673 seems to add this feature. Would you mind taking a look?

vitalik commented 1 year ago

@Jocelyn-AGORO

Just be carefull never expose all GET params into orm filter as some one can explore database by querying some related data

overal #673 should give you option to expose OpenAPI params to query nicely from database