fix: re-fetch plant after photo upload so gallery and hero see new photo
This commit is contained in:
parent
cbd4ba09aa
commit
be9d6caf94
1 changed files with 2 additions and 1 deletions
|
|
@ -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})
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue