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 views.py 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 urls.py 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
WalGA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.