Объект 'NoneType' не имеет атрибута 'HTTP_200_OK' в Django Rest Framework [закрыто]

Я работаю над определенным проектом в drf и создал представление для поиска записей о работе, но всякий раз, когда я пытаюсь использовать свою конечную точку, я получаю ошибку. Ниже приведены соответствующие блоки кода:

models.py

class Customer(models.Model):
    firstname = models.CharField(max_length=100, null=False, blank=False)
    othernames = models.CharField(max_length=100, null=True, blank=False)
    phonenumber_1 = models.CharField(max_length=15, null=False, blank=False)
    phonenumber_2 = models.CharField(max_length=15, null=True, blank=True)
    email = models.EmailField(blank=True, null=True)
    address = models.CharField(max_length=64, null=False, blank=False)
    passport_photo = models.ImageField(upload_to="passport_photos/", null=False, blank=False)
    file_upload = models.FileField(upload_to="uploaded_files/", null=False, blank=False)
    remarks = models.TextField()


class Job(models.Model):
    job_title = models.CharField(max_length=64, null=False, blank=False)
    job_position = models.ForeignKey(JobPosition, null=True, on_delete=models.CASCADE)
    job_field = models.CharField(max_length=64, null=True, blank=True)
    job_description = models.TextField(null=True, blank=True)
    job_company = models.ForeignKey(EmployerCompany, null=True, blank=True, on_delete=models.CASCADE)


class RecruitmentProcess(models.Model):
    STATUS_CHOICES = [
        ('applied', 'Applied'),
        ("pending", "Pending"),
        ('interviewed', 'Interviewed'),
        ('not_hired', 'Not Hired'),
        ('hired', 'Hired'),
        ('rejected_offer', 'Rejected the Offer'),
    ]

    customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
    job = models.ForeignKey(Job, on_delete=models.CASCADE)
    status = models.CharField(max_length=64, choices=STATUS_CHOICES, default='applied')
    application_date = models.DateTimeField(auto_now_add=True)

urls.py

urlpatterns = [
   path('placements/search/', views.search_placement, name='placement_search'),
]

serializers.py

from rest_framework import serializers
from.models import RecruitmentProcess
from rest_framework.response import Response

def create_standard_response(status, message, data=None):
    response = {
        'status': status,
        'message': message,
    }
    if data is not None:
        response['data'] = data
    return Response(response)

class RecruitmentProcessSerializer(serializers.ModelSerializer):
    class Meta(object):
        model = RecruitmentProcess 
        fields = "__all__"

views.py

from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
from .serializers RecruitmentProcessSerializer
from django.db.models import Q

@api_view(['GET'])
def search_placement(request):
    query_params = request.query_params
    filters = Q()

    customer = query_params.get('customer')
    if customer:
        filters &= (Q(customer__firstname__icontains=customer) | 
                    Q(customer__othernames__icontains=customer) | 
                    Q(customer__email__icontains=customer) | 
                    Q(customer__phonenumber_1__icontains=customer) | 
                    Q(customer__phonenumber_2__icontains=customer))

    job = query_params.get('job')
    if job:
        filters &= (Q(job__job_title__icontains=job) | 
                    Q(job__job_field__icontains=job) | 
                    Q(job__job_description__icontains=job) | 
                    Q(job__job_company__name__icontains=job))

    status = query_params.get('status')
    if status:
        filters &= Q(status__icontains=status)

    placements = RecruitmentProcess.objects.filter(filters)
    serializer = RecruitmentProcessSerializer(placements, many=True)

    return create_standard_response(
        status=status.HTTP_200_OK,
        message="Customer search results retrieved successfully",
        data=serializer.data
    )

Я попробовал протестировать конечную точку для поиска мест размещения, но продолжаю получать следующую ошибку

AttributeError at /placements/search/
'NoneType' object has no attribute 'HTTP_200_OK'
Request Method: GET
Request URL:    http://127.0.0.1:8000/placements/search/?customer=eria
Django Version: 5.0.6
Exception Type: AttributeError
Exception Value:    
'NoneType' object has no attribute 'HTTP_200_OK'
Exception Location: /home/eria/Desktop/digivolve/independent app/digi_app/views.py, line 572, in search_placement
Raised during:  digi_app.views.search_placement
Python Executable:  /home/eria/Desktop/digivolve/independent app/venv/bin/python
Python Version: 3.12.3
Python Path:    
['/home/eria/Desktop/digivolve/independent app',
 '/usr/lib/python312.zip',
 '/usr/lib/python3.12',
 '/usr/lib/python3.12/lib-dynload',
 '/home/eria/Desktop/digivolve/independent '
 'app/venv/lib/python3.12/site-packages']
Server time:    Fri, 07 Jun 2024 06:40:08 +0000

получаю сообщение об ошибке

Вернуться на верх