Fernet cryptography.fernet djnago

Я использую cryptography.fernet в своем views.py и получаю эту ошибку:

 File "C:\Users\DIDAM\Desktop\venv\Lib\site-packages\rest_framework\fields.py", line 479, in   get_attribute
 raise type(exc)(msg)
 AttributeError: Got AttributeError when attempting to get a value for field `course` on    serializer `SectionSerializer`.
 The serializer field might be named incorrectly and not match any attribute or key on the `int`     instance.
 Original exception text was: 'int' object has no attribute 'course'.
 [18/Jan/2023 09:01:55] "GET /api/chapter-section-list/1/ HTTP/1.1" 500 140636

вот мой views.py:

  class ChapterSectionList(generics.ListAPIView):
  serializer_class=SectionSerializer

  def get_queryset(self):
    chapter_id=self.kwargs['chapter_id']
    chapter=models.Chapter.objects.get(pk=chapter_id)
    section=models.Section.objects.filter(chapter=chapter)

    cipher = AES.new(key, AES.MODE_CBC, iv)
  
    data = b'"{section}"'
    cipher = Fernet(b'NWRmMTk3ZWUwY2RjNjA3NWY4NzQ2NmQyOGRkYzczMmM=')

    encrypted_data = cipher.encrypt(data)

    encoded_data = base64.b64encode(encrypted_data)
    return encrypted_data

Мне нужна помощь, чтобы решить мою ошибку

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