Skip to content

Commit

Permalink
storage fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ramibch committed Jan 5, 2024
1 parent e6ce991 commit eea5367
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
"default": {
"BACKEND": MEDIA_STORAGE_BACKEND,
},
"local": {
"local": { # not used at the moment: 05.01.2024
"BACKEND": "django.core.files.storage.FileSystemStorage",
"OPTIONS": {
"location": BASE_DIR / "media",
Expand Down
7 changes: 2 additions & 5 deletions core/models/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from django.contrib.auth import get_user_model
from django.contrib.sessions.models import Session
from django.core.files.base import ContentFile
from django.core.files.storage import default_storage as storage
from django.core.files.storage import storages
from django.core.files.storage import default_storage
from django.db import models
from django.db.models import Q
from django.urls import reverse
Expand Down Expand Up @@ -442,9 +441,7 @@ def crop_photo(self):
cropped_image = image.crop(cropping_area)
resized_image = cropped_image.resize((300, 300), Image.LANCZOS)

# TODO: this code need to be improved
# the field Profile.cropped_photo has already a specified storage object
fh = storages["local"].open(self.cropped_photo.name, "wb")
fh = default_storage.open(self.cropped_photo.name, "wb")
resized_image.save(fh, "png")
fh.close()

Expand Down

0 comments on commit eea5367

Please sign in to comment.