嘿,为什么我不能在 django 中使用非主键字段进行原始查询,它没有给出 table found

Hey why am i not able to make a raq query in django with non primary key fields it is giving no such table found

我制作的模型如下这是在home/models.py

中定义的
class likes(models.Model):
    like_id=models.AutoField(primary_key=True)
    post_id=models.ForeignKey(post,on_delete=models.CASCADE)
    liker_user=models.ForeignKey(User,on_delete=models.CASCADE)
    date_liked=models.DateField(default=datetime.date.today)

在搜索中我制作了 search/views.py,如下所示并出现错误

def search_query(request):
    print(request.POST['search_query'])
    x=likes.objects.raw("Select Like_id,Post_id from home_likes")
    # Operational Error: No column found Post_id
    print(x)
    print(len(x))
    return render(request,'search/search_query_page.html')

# your query should select the column like_id, post_id_id. Because if you check in your database table it is post_id_id, not post_id.
x=likes.objects.raw('SELECT like_id, post_id_id FROM home_likes'):

def search_query(request):
    print(request.POST['search_query'])
    x=likes.objects.raw('SELECT like_id, post_id_id FROM home_likes'):
    print(x)
    print(len(x))
    return render(request,'search/search_query_page.html')