diff options
author | luxagraf <sng@luxagraf.net> | 2017-09-23 16:48:54 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2017-09-23 16:48:54 -0500 |
commit | 821fc221c86cd0630042aecc4bb6cddd9464208b (patch) | |
tree | 8c3479b1315deeb55e78886ccbe1b9583f90ddbc /app/books/models.py | |
parent | ef2fbc67a923e4d39f0497943c11dc1eaeb74f5d (diff) |
pulled in changes on arch server
Diffstat (limited to 'app/books/models.py')
-rw-r--r-- | app/books/models.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/books/models.py b/app/books/models.py index 4359a3e..4362bc9 100644 --- a/app/books/models.py +++ b/app/books/models.py @@ -7,6 +7,10 @@ from django.template.defaultfilters import slugify from utils.widgets import markdown_to_html +def get_upload_path(self, filename): + return "images/book-covers/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) + + class Book(models.Model): title = models.CharField(max_length=200) author_name = models.CharField(max_length=200) @@ -31,7 +35,7 @@ class Book(models.Model): rating = models.CharField(max_length=1, choices=RATINGS, null=True, blank=True) enable_comments = models.BooleanField(default=False) is_public = models.BooleanField(default=True) - image = models.FileField(upload_to="%s/%s" % (settings.IMAGES_ROOT, 'book-covers/'), null=True, blank=True) + image = models.FileField(upload_to=get_upload_path, null=True, blank=True) class Meta: ordering = ('-read_date',) |