diff --git a/photologue/views.py b/photologue/views.py index 85833cc..3560090 100644 --- a/photologue/views.py +++ b/photologue/views.py @@ -183,10 +183,10 @@ class GalleryDownload(LoginRequiredMixin, DetailView): # Create zip file with pictures gallery = self.get_object() - gallery_year = Path("/photos/" + str(+gallery.date_start.year)) - gallery_zip = gallery_year / (gallery.slug + ".zip") + gallery_year = os.path.join("/photos/", str(gallery.date_start.year)) + gallery_zip = os.path.join(gallery_year, (gallery.slug + ".zip")) - with open(settings.MEDIA_ROOT + str(gallery_zip), "wb") as zip_bytes: # I hate pathlib + with open(os.path.join(settings.MEDIA_ROOT, gallery_zip), "wb") as zip_bytes: zip_file = zipfile.ZipFile(zip_bytes, "w") for photo in gallery.photos.filter(is_public=True): filename = os.path.basename(os.path.normpath(photo.image.path)) @@ -196,7 +196,7 @@ class GalleryDownload(LoginRequiredMixin, DetailView): # Return the path to it return redirect( - settings.MEDIA_URL + str(gallery_zip).replace("\\", "/") + os.path.join(settings.MEDIA_URL, str(gallery_zip)).replace("\\", "/") ) # windows fix # Return zip file