Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
706 views
in Technique[技术] by (71.8m points)

from rest_framework.filters import SearchFilter generates error as cannot import name 'ORDER_PATTERN' from 'django.db

I found out that the line from rest_framework.filters import SearchFilter generates me an error as

 from django.db.models.sql.constants import ORDER_PATTERN
ImportError: cannot import name 'ORDER_PATTERN' from 'django.db.models.sql.constants' (E:anacondaenvsAHG_weblibsite-packagesdjangodbmodelssqlconstants.py)

I used that as below:

class op_ViewSet(viewsets.ModelViewSet) :
    # permission_classes = (permissions.IsAuthenticated,)

    queryset = Op.objects.all().filter()
    serializer_class = op_Serializer
    # authentication_classes = [TokenAuthentication , SessionAuthentication , BasicAuthentication]
    # pagination_class = PageNumberPagination
    # pagination_class = StandardResultsSetPagination
    filter_backends = [DjangoFilterBackend , SearchFilter]
    filter_class = op_filter
    ordering_fields = ['close_date' , ]
    ordering = ['close_date']
    search_fields = ['website' , 'title' , 'description' , 'organization__name']

    @action(detail=True , methods=['Get'])
    def attachments(self , request , pk) :
        op = self.get_object()
        links = Attachments.objects.filter(op_id=op.id)
        serializer = attachments_Serializer(links , many=True)
        return Response(serializer.data)

previously it was working fine, can anyone help me with the solution.

question from:https://stackoverflow.com/questions/65640970/from-rest-framework-filters-import-searchfilter-generates-error-as-cannot-import

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...