Django: models.Model.objects.filter(pk) return nothing [closed]

I started learn Django framework. Following the official tutorial I have model Question that is derived from django.db.models.Model After all migrations, In I created function called detail that is supposed to show me question by quest_id here is the code

def detail(request, quest_id):
    by_id = Question.objects.filter(id=quest_id).first()
    by_index = Question.objects.all()[quest_id]
    response = f"Via filter \"{by_id}\" Via index \"{by_index}\""
    return HttpResponse(response)

In I added corresponding path to urlpatterns

Next I added two records of Question to my database, but when I tried to Question.objects.filter(quest_id).first(), I've always get None even if I have Question with id=quest_id Here Is result of detail for id quest_id

Back to Top