Code Room
Code reviewMedium
Question
Review this Python (Django) view that increments an article's view counter and updates last-seen.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
def record_view(request, article_id): article = Article.objects.get(pk=article_id) if article.status != "published": return HttpResponse(status=404) article.views = article.views + 1 article.last_viewed = timezone.now() article.save() log_view(request.user, article) return HttpResponse(status=204)Run or narrate your approach, then ask the coach.