I have this problem while using the Django Rest Framework. I am trying to do a get request using patient id. Now, lets say I look for patientid=6, the api returns results with patientid=6 ,patientid=26 and any ids that contain the number '6'. It looks like it searches for a substring.I want to make it work such that patient id=6 returns only the patientid results with id =6
serializers.py
class Radiologypdfserializerdata(serializers.ModelSerializer):
class Meta:
model = models.Radiologypdf
fields = (
'patientid',
'testinfo',
'clinicalindication',
'attendingdoctor',
'patientname',
'age',
'mobilenumber',
'sex',
'email',
'doctorsname',
'doctorsregistrationnumber',
'clinicname',
'doctorstelno',
'createdtime',
'radiology_id',
'created',
)
api.py
class RadiologypdfViewSet(viewsets.ModelViewSet):
"""ViewSet for the radiology class"""
queryset = models.Radiologypdf.objects.all()
serializer_class = serializers.Radiologypdfserializerdata
permission_classes = [permissions.IsAuthenticated]
filter_backends = (filters.SearchFilter,)
search_fields = ('patientid','radiology_id')