fix: re-fetch plant after photo upload so gallery and hero see new photo

This commit is contained in:
Stephan Kerkman 2026-05-30 21:33:22 +02:00
parent cbd4ba09aa
commit be9d6caf94

View file

@ -211,9 +211,10 @@ def crop_thumbnail(request, pk):
def upload_photo(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'): if request.FILES.get('image'):
PlantPhoto.objects.create(plant=plant, image=request.FILES['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}) return render(request, 'plants/partials/photo_gallery.html', {'plant': plant})