blob: e20530ba9217db7a62028bd02ca5eb39d2adab66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import datetime
from django.db import models
def get_upload_path(self, filename):
return "images/projects/gifs/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
class AnimatedGif(models.Model):
title = models.CharField(max_length=254)
gif = models.ImageField(upload_to=get_upload_path)
slug = models.SlugField()
date_created = models.DateField('Date Created')
music_ogg = models.FileField(upload_to=get_upload_path, blank=True, null=True)
music_mp3 = models.FileField(upload_to=get_upload_path, blank=True, null=True)
class Meta:
verbose_name_plural = "Animated Gifs"
app_label = 'projects'
ordering = ('-date_created',)
# Returns the string representation of the model.
def __unicode__(self):
return self.slug
def get_absolute_url(self):
return '/projects/gifs/%s/' %(self.slug)
|