Fix file name display in dream view
This commit is contained in:
parent
0161ef48fb
commit
369103b081
2 changed files with 7 additions and 1 deletions
|
@ -3,6 +3,8 @@ from django.core.validators import MaxValueValidator, MinValueValidator
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
|
||||||
from mood.models import Mood
|
from mood.models import Mood
|
||||||
from common.helpers import get_upload_path
|
from common.helpers import get_upload_path
|
||||||
|
|
||||||
|
@ -48,6 +50,10 @@ class DreamMedia(models.Model):
|
||||||
dream = models.ForeignKey(Dream, models.CASCADE)
|
dream = models.ForeignKey(Dream, models.CASCADE)
|
||||||
media = models.FileField(get_upload_path)
|
media = models.FileField(get_upload_path)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def basename(self):
|
||||||
|
return os.path.basename(self.media.name)
|
||||||
|
|
||||||
class ThemeRating(models.Model):
|
class ThemeRating(models.Model):
|
||||||
theme = models.ForeignKey(Theme, models.CASCADE)
|
theme = models.ForeignKey(Theme, models.CASCADE)
|
||||||
name = models.CharField(max_length=64)
|
name = models.CharField(max_length=64)
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<ul>
|
<ul>
|
||||||
{% for attachment in object.dreammedia_set.all %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue