oacpl/newsroom/models.py

23 lines
599 B
Python
Raw Normal View History

2018-02-25 23:48:34 -05:00
from django.db import models
from django.contrib.auth.admin import User
class Attachment(models.Model):
file = models.FileField(upload_to='PressRelease')
def name(self):
return self.file.name.replace('PressRelease/', '')
def __str__(self):
return self.file.name
class PressRelease(models.Model):
title = models.CharField(max_length=255)
created = models.DateTimeField(auto_now_add=True)
2018-05-24 16:11:59 -04:00
creator = models.ForeignKey(User, on_delete=models.DO_NOTHING)
2018-02-25 23:48:34 -05:00
attachments = models.ManyToManyField(Attachment)
def __str__(self):
return self.title