diff --git a/plants/views/plants.py b/plants/views/plants.py index d07d3ac..b74702b 100644 --- a/plants/views/plants.py +++ b/plants/views/plants.py @@ -211,9 +211,10 @@ def crop_thumbnail(request, pk): def upload_photo(request, pk): - plant = get_object_or_404(Plant.objects.prefetch_related('photos'), pk=pk) + plant = get_object_or_404(Plant, pk=pk) if request.FILES.get('image'): PlantPhoto.objects.create(plant=plant, image=request.FILES['image']) + plant = Plant.objects.prefetch_related('photos').get(pk=pk) return render(request, 'plants/partials/photo_gallery.html', {'plant': plant})