Skip to content

Commit

Permalink
Change backend images from static to media
Browse files Browse the repository at this point in the history
  • Loading branch information
KwikKill committed Oct 8, 2023
1 parent 0fecb58 commit 79c8271
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 1 addition & 4 deletions insalan/partner/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from insalan.settings import STATIC_URL


class Partner(models.Model):
class PartnerType(models.TextChoices):
"""There are two types of sponsors"""
Expand All @@ -27,7 +24,7 @@ class Meta:
url: models.URLField = models.URLField(verbose_name=_("URL"))
logo: models.FileField = models.FileField(
verbose_name=_("Logo"),
upload_to=os.path.join(STATIC_URL, "partners"),
upload_to="partners",
validators=[
FileExtensionValidator(allowed_extensions=["png", "jpg", "jpeg", "svg"])
],
Expand Down
5 changes: 4 additions & 1 deletion insalan/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@
# https://docs.djangoproject.com/en/4.1/howto/static-files/

STATIC_URL = "v1/static/"
STATIC_ROOT = getenv("STATIC_ROOT", path.join(BASE_DIR, "static/"))
STATIC_ROOT = "v1/" + getenv("STATIC_ROOT", "static/")

MEDIA_URL = 'v1/media/'
MEDIA_ROOT = 'v1/' + getenv("MEDIA_ROOT", "media/")

# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
Expand Down
6 changes: 2 additions & 4 deletions insalan/tournament/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
)
from django.utils.translation import gettext_lazy as _

from insalan.settings import STATIC_URL
from insalan.user.models import User


class Event(models.Model):
"""
An Event is any single event that is characterized by the following:
Expand Down Expand Up @@ -60,7 +58,7 @@ class Event(models.Model):
verbose_name=_("Logo"),
blank=True,
null=True,
upload_to=os.path.join(STATIC_URL, "event-icons"),
upload_to="event-icons",
validators=[
FileExtensionValidator(allowed_extensions=["png", "jpg", "jpeg", "svg"])
],
Expand Down Expand Up @@ -156,7 +154,7 @@ class Tournament(models.Model):
verbose_name=_("Logo"),
blank=True,
null=True,
upload_to=os.path.join(STATIC_URL, "tournament-icons"),
upload_to="tournament-icons",
validators=[
FileExtensionValidator(allowed_extensions=["png", "jpg", "jpeg", "svg"])
],
Expand Down

0 comments on commit 79c8271

Please sign in to comment.