Senior
19 agosto 2026Trova il bug: Django
Uno snippet di codice. Trova il bug, o dimostra che non ce n'è.
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})Clicca sulle righe che causano il problema.
Il tuo verdetto
Un tentativo al giorno. La risposta appare subito dopo.
Mantieni la tua serie
Crea un account per conservare la tua serie e seguire i tuoi progressi.