From ec1d5e2595b660126bd7bbeb6ed99a6ec8f9e064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mih=C3=A1lik?= Date: Sat, 14 Dec 2024 23:24:29 +0100 Subject: [PATCH] Use relative urls in publication file field --- competition/models.py | 2 +- competition/serializers.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/competition/models.py b/competition/models.py index 140204d..132e25c 100644 --- a/competition/models.py +++ b/competition/models.py @@ -736,7 +736,7 @@ class Meta: event = models.ForeignKey(Event, null=True, on_delete=models.SET_NULL) file = RestrictedFileField( - upload_to='publications/%Y', + upload_to='publications/%Y/', content_types=['application/pdf', 'application/zip'], verbose_name='súbor') diff --git a/competition/serializers.py b/competition/serializers.py index 3222368..eb60b12 100644 --- a/competition/serializers.py +++ b/competition/serializers.py @@ -42,6 +42,11 @@ class Meta: model = models.Publication fields = '__all__' + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.fields['file'].parent = None + def get_verbose_name(self, obj): return str(obj)