Open Gibsondz opened 4 months ago
@Gibsondz, thanks a lot.
Faced the same issue. Solution looks nice enough. Works for me.
I'd recommend forking the repo and creating a pull request with the solution (and mention the issue in it), that would be easier to understand, imho.
I know that 3.15 is not part of the the supported versions of DRF yet but I thought this would be useful to bring up. This is my first time doing something like this so please let me know if it's off base.
Ran into this when I was looking to use a custom url converter and attempting to apply the converter to nested URLs using NestedSimpleRouter
When use_regex_path=False on SimpleRouter it will strip the regex ^ and $ characters from the router routes causing the following line to not properly pre-pend the parent_prefix to the route.
DRF 3.15 regex strip:
NestedMixin's route replacement for regex ^ character
route_contents['url'] = route.url.replace('^', '^' + escaped_parent_regex)
The '^' does not exist in this case and the router fails silently not pre-pending any parent to the route.
Example to reproduce is to use DRF 3.15 and set up the following urls.py:
I made quick and dirty fix locally by doing something like below: