From 178fa098f5c9536ddcab57c9cdd43350b2106494 Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 6 Jan 2021 14:03:13 +0100 Subject: [PATCH] Fix file name display in status view --- mood/models.py | 6 ++++++ mood/templates/mood/status_view.html | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mood/models.py b/mood/models.py index 76faf7e..7ba28fa 100644 --- a/mood/models.py +++ b/mood/models.py @@ -3,6 +3,8 @@ from django.contrib.auth import get_user_model from django.core.validators import MaxValueValidator, MinValueValidator from django.utils import timezone +import os.path + from colorfield.fields import ColorField from common.helpers import get_upload_path @@ -48,6 +50,10 @@ class StatusMedia(models.Model): status = models.ForeignKey(Status, models.CASCADE) file = models.FileField(get_upload_path) + @property + def basename(self): + return os.path.basename(self.file.name) + class StatusActivity(models.Model): status = models.ForeignKey(Status, models.CASCADE) activity = models.ForeignKey(Activity, models.CASCADE) diff --git a/mood/templates/mood/status_view.html b/mood/templates/mood/status_view.html index af19bcd..c4bee19 100644 --- a/mood/templates/mood/status_view.html +++ b/mood/templates/mood/status_view.html @@ -59,7 +59,7 @@