i have views (readonlymodel)
class Test(ReadOnlyModelViewSet):
queryset = Test.objects.all()
lookup_field = 'art'
serializer_class = TestSerializer
@action(methods=['GET'], detail=True)
def chars(self, request, art):
....
also urls:
router = routers.SimpleRouter()
router.register(r'api/test', Test)
I need lookup_field to work for art with multiple slashes. Example art: "first_product/test" But action chars is also needed. Example 'first_product/test/chars'
Examples of queries that should work:
0.0.0.0:8000/api/test/first_product/test
0.0.0.0:8000/api/test/first_product/test/chars
0.0.0.0:8000/api/test/second_product
0.0.0.0:8000/api/test/second_product/chars
I tried to do it through lookup_value_regex, but unfortunately it didn't work out that way, either /chars doesn't work, or with /chars works, but it doesn't see without it. Those works either this or that:
0.0.0.0:8000/api/test/first_product/test
0.0.0.0:8000/api/test/first_product/test/chars
i tried: this worked for 'test/teste/chars'
lookup_value_regex = '.*?(?=\/chars)'
for 'test/test'
lookup_value_regex = '.*'