class Slide models Model title models CharField max_length 50 added mo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
class Slide(models.Model):
title = models.CharField(max_length=50)
added = models.DateTimeField()
file = models.FileField(upload_to='i/slides')
width = models.IntegerField(blank=True, null=True)
height = models.IntegerField(blank=True, null=True)
richfile = models.FileField(upload_to='i/rich', blank=True, null=True)
richwidth = models.IntegerField(blank=True, null=True)
richheight = models.IntegerField(blank=True, null=True)
text = models.TextField(blank=True)
project = models.ForeignKey(Project)
def get_mimetype (self):
type = self.file.split('.').pop()
mime = 'application'
if type == 'jpg':
mime = 'image/jpeg'
elif type == 'swf':
mime = 'application/x-shockwave-flash'
return mime