[Answered ]-How to check a request.user with raw sql in Django

1👍

You work with a parameter, so:

def profile(request):
    with connection.cursor() as cursor:
        cursor.execute('SELECT * FROM Student WHERE ID = %s', [request.user.id])
        data = dictfetchall(cursor)
    return render(request, 'personal.html', {'data': data})

however using raw queries is often not a good idea.

Leave a comment