Новичок в Django, я хотел бы узнать, как получить поля таблицы Consultation, начиная с таблицы Students?

Вот какую ошибку я получаю

ProgrammingError at /Action/PassagePerso/19E000183/

operator does not exist: character varying = numeric
LINE 1: ...on", public."Actions_students" WHERE matricule_id = 19E00018...
                                                             ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

Request Method:     GET
Request URL:    http://127.0.0.1:8000/Action/PassagePerso/19E000183/
Django Version:     4.1.2
Exception Type:     ProgrammingError
Exception Value:    

operator does not exist: character varying = numeric
LINE 1: ...on", public."Actions_students" WHERE matricule_id = 19E00018...
                                                             ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

Exception Location:     /home/jasonfofana/D/Workspace/PYTHON/Projects/Pharmacy_school/venv/lib/python3.10/site-packages/django/db/backends/utils.py, line 89, in _execute
Raised during:  Actions.views.ConsultationPersonnelle
Python Executable:  /home/jasonfofana/D/Workspace/PYTHON/Projects/Pharmacy_school/venv/bin/python
Python Version:     3.10.4
Python Path:    

['/home/jasonfofana/D/Workspace/PYTHON/Projects/Pharmacy_school',
 '/usr/lib/python310.zip',
 '/usr/lib/python3.10',
 '/usr/lib/python3.10/lib-dynload',
 '/home/jasonfofana/D/Workspace/PYTHON/Projects/Pharmacy_school/venv/lib/python3.10/site-packages']

Server time:    Wed, 02 Nov 2022 02:42:05 +0000

Я хотел бы использовать две таблицы Консультации и Студенты в отношениях для отображения информации о человеке

def ConsultationPersonnelle(request, pk_student):
    student = Students.objects.get(pk=pk_student)
    consult = Students.objects.raw(f'SELECT * from public."Actions_consultation", public."Actions_students" WHERE matricule_id = {student.matricule} and matricule = {student.matricule}')

context = {'consultant': consult}

return render(request, 'consult_perso.html', context)
Вернуться на верх