Senior
August 19, 2026

Spot the bug: Django

One snippet. Find the bug, or prove there isn't one.

python
1import logging
2from django.http import JsonResponse
3from .models import Article
4
5logger = logging.getLogger(__name__)
6
7def get_article(request, slug):
8    try:
9        article = Article.objects.get(slug=slug)
10    except Article.DoesNotExist:
11        logger.error("Article not found: slug=%s", slug)
12        return JsonResponse({"error": "Not found"}, status=404)
13    return JsonResponse({"title": article.title, "body": article.body})

Click the lines that carry the problem.

Your verdict

One attempt per day. The answer shows up right after.

Keep your streak

Create an account to keep your streak and track your progress.

Create an account