miki725 / django-url-filter

Django URL Filter provides a safe way to filter data via human-friendly URLs.
http://django-url-filter.readthedocs.io/
Other
334 stars 77 forks source link

CoreAPIURLFilterBackend causing recursion depth exceeded #94

Open aslebloas opened 4 years ago

aslebloas commented 4 years ago

Hello,

I tried to use CoreAPIURLFilterBackend to have the filters parameters showing up in our swagger documentation, but I have an errormaximum recursion depth exceeded when trying to access the documentation url. It comes from:

/url_filter/integrations/drf_coreapi.py" in _all_filters
60.             for i in _all_filters(field, prefix=prefix + (name,)):

ModelViewSet is as such:

class ViewSet(ModelViewSet):
    filter_backends = [CoreAPIURLFilterBackend]
    filter_fields = ("id", "start_date", "status", "created_at", "updated_at")
    pagination_class = LargeResultSetPagination
    permission_classes = (permissions.IsAuthenticated)
    serializer_class = ViewSetSerializer

I tried this configuration but it would not fix it.

Django==2.2.9
django-url-filter==0.3.14

Would you have some ideas how to solve this issue? Thank you very much.

miki725 commented 4 years ago

dont think I have tested core api when viewset defines filterset. have you tried creating filterset explicitly?

aslebloas commented 4 years ago

Yes, and I run into the same problem. Do you have any ideas?

miki725 commented 4 years ago

hmm. usually worked for me. probably there is some edge case with some relations where it attempts to go in infinite loop.

nmerty commented 4 years ago

Goes into a infinite loop if a reference field is included in the FilterSet. @miki725 do you think it is simple to fix?

simone6021 commented 3 years ago

Run into the same issue, but did not had the time to look into thoroughly. By the way i think that is because allow_related_reverse True by default: if a model has "circular" relations, this issue comes in.

Hope to have the time to look for a solution this weekend.