django-url-filter icon indicating copy to clipboard operation
django-url-filter copied to clipboard

CoreAPIURLFilterBackend causing recursion depth exceeded

Open aslebloas opened this issue 5 years ago • 5 comments

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.

aslebloas avatar Feb 04 '20 20:02 aslebloas

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

miki725 avatar Feb 07 '20 14:02 miki725

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

aslebloas avatar Feb 15 '20 23:02 aslebloas

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

miki725 avatar Feb 15 '20 23:02 miki725

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

nmerty avatar Jul 21 '20 17:07 nmerty

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.

simone6021 avatar Nov 16 '20 13:11 simone6021