📝 Support `Path` with `*args` (#754)
Right now
Path component only supports parsing from request.kwargs. Which is like 99% of cases.However, parsing from
request.args is not supported:django-modern-rest/dmr/components.py
Lines 655 to 662 in b3f9c08
What should we do instead?
1. When
request.args is provided we should require models like:>>> import pydantic
>>> class UserId(pydantic.BaseModel):
... user_id: int
>>> PathModel = pydantic.RootModel[tuple[tuple[int, ...], UserId]]
>>> PathModel.model_validate((('1', '2', '3'), {'user_id': 10}))
RootModel[tuple[tuple[int, ...], UserId]](root=((1, 2, 3), UserId(user_id=10)))
1. We would return
tuple[Args, Kwargs] from this component if request.args is set2. Test this with unnamed
re_path urls https://docs.djangoproject.com/en/6.0/topics/http/urls/#using-unnamed-regular-expression-groups3. Test this in
tests/test_unit/test_components/test_path.py4. Document this feature in
docs/pages/components/path.rst5. Provide an example in
docs/examples/components/path_args.py and include it to path.rst6. Provide a changelog entry
7. Remove
_UNNAMED_PATH_PARAMS_MSG and all translations of this string, recompile all translations with make translationsContributions are welcome! This is an intermediate level task :)
#enhancement #good_first_issue #help_wanted #django_modern_rest
sent via relator