diff --git a/photologue/views.py b/photologue/views.py index 8fd57d3..bf81c3c 100644 --- a/photologue/views.py +++ b/photologue/views.py @@ -22,6 +22,8 @@ from django.views.generic.edit import DeleteView, FormView from PIL import Image from django.contrib.auth import get_user_model +from django.db import models + from .forms import UploadForm from .models import Gallery, Photo, Tag @@ -162,6 +164,13 @@ class GalleryDetailView(LoginRequiredMixin, DetailView): if "owner" in self.kwargs: context["photos"] = context["photos"].filter(owner__id=self.kwargs["owner"]) + #Increment the photo view count + + for photo in context["photos"]: + photo.increment_count() + + self.object.bulk_update(context["photos"],["increment_count"]) + return context