Raw query date problem

Hi! I try to use these queries below on a page to get data between two dates:

def szd_by_date_szervezetielegedettseg(request, projekt_id, projekt_bydate_id):

    fd = Projekt_szd_by_date.objects.raw('SELECT stressz_projekt_szd_by_date.date_from AS date_from FROM stressz_projekt_szd_by_date WHERE stressz_projekt_szd_by_date.id = %s', [projekt_bydate_id])
    td = Projekt_szd_by_date.objects.raw('SELECT stressz_projekt_szd_by_date.date_to AS date_to FROM stressz_projekt_szd_by_date WHERE stressz_projekt_szd_by_date.id = %s', [projekt_bydate_id])
    
    projekt_by_date = Projekt_szd_by_date.objects.raw('SELECT * FROM stressz_projekt_szd_by_date INNER JOIN stressz_projekt ON stressz_projekt.id = stressz_projekt_szd_by_date.id INNER JOIN stressz_elegedettseg  WHERE stressz_elegedettseg.date BETWEEN %s AND %s AND stressz_projekt_szd_by_date.projekt_szd=%s LIMIT 1', [fd, td, projekt_bydate_id])

I have a model stressz_elegedettseg from which I want to use the date filed added automatically when the object is created.
I like to use the date range from the stressz_projekt_szd_by_date model that I add manually.

If I refresh the page it gives me this error:

Error binding parameter 0 - probably unsupported type.

If I add two dates manually to the query like 2021-01-01 it works well but with dynamic data it works not.
I’m new to Django and programming. What am I doing wrong?

You mentioned that you’re new to Django.

Have you worked your way through the official Django tutorial? If you haven’t, I strongly suggest it.

Generally speaking, building raw queries in Django is an anti-pattern. You should have models representing those tables and allow the ORM to perform the data format conversions for you.