Code Room
Code reviewMediumcr-g209
Subject Lost updateLevel Mid–Senior~20 minCommon in Code quality & review interviewsIndustries Software development

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.

Talk through your review
Code to reviewpython
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.