Fix file name display in dream view

This commit is contained in:
Kumi 2021-01-06 14:05:31 +01:00
parent 178fa098f5
commit 82e7b262e2
2 changed files with 7 additions and 1 deletions

View file

@ -3,6 +3,8 @@ from django.core.validators import MaxValueValidator, MinValueValidator
from django.utils import timezone
from django.contrib.auth import get_user_model
import os.path
from mood.models import Mood
from common.helpers import get_upload_path
@ -48,6 +50,10 @@ class DreamMedia(models.Model):
dream = models.ForeignKey(Dream, models.CASCADE)
media = models.FileField(get_upload_path)
@property
def basename(self):
return os.path.basename(self.media.name)
class ThemeRating(models.Model):
theme = models.ForeignKey(Theme, models.CASCADE)
name = models.CharField(max_length=64)

View file

@ -59,7 +59,7 @@
<div class="container">
<ul>
{% for attachment in object.dreammedia_set.all %}
<li><a href="{{ attachment.media.url }}">{{ attachment.media.name }}</a></li>
<li><a href="{{ attachment.media.url }}">{{ attachment.basename }}</a></li>
{% endfor %}
</ul>
</div>