ernestophone.ens.fr/partitions/models.py

26 lines
693 B
Python
Raw Normal View History

2015-03-17 19:03:51 +01:00
from django.db import models
import os
import Ernestophone.settings
class Partition(models.Model):
nom = models.CharField(max_length=100)
part = models.FileField(upload_to="partitions/")
morceau = models.ForeignKey('PartitionSet')
def __str__(self):
return self.nom
def delete(self, *args, **kwargs):
os.remove(os.path.join(Ernestophone.settings.MEDIA_ROOT, self.part.name))
super(Partition, self).delete(*args, **kwargs)
class PartitionSet(models.Model):
nom = models.CharField(max_length=100)
auteur = models.CharField(max_length=100)
def __str__(self):
return self.nom + " - " + self.auteur
# Create your models here.