diff --git a/insalan/partner/models.py b/insalan/partner/models.py index e889ca7b..4701735d 100644 --- a/insalan/partner/models.py +++ b/insalan/partner/models.py @@ -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""" @@ -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"]) ], diff --git a/insalan/settings.py b/insalan/settings.py index c99d36c8..6f7cfdbd 100644 --- a/insalan/settings.py +++ b/insalan/settings.py @@ -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 diff --git a/insalan/tournament/models.py b/insalan/tournament/models.py index 3a1955e1..1402e46f 100644 --- a/insalan/tournament/models.py +++ b/insalan/tournament/models.py @@ -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: @@ -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"]) ], @@ -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"]) ],