depot/web/quotes/quotedb/models.py

28 lines
767 B
Python
Raw Normal View History

2021-01-19 03:51:22 +00:00
import datetime
from django.db import models
from django.contrib.auth import models as auth_models
class Person(models.Model):
name = models.CharField(null=False, unique=True, blank=False, max_length=120)
2021-01-19 23:43:43 +00:00
user = models.ForeignKey(
auth_models.User, null=True, default=None, on_delete=models.SET_NULL
)
2021-01-19 03:51:22 +00:00
def __str__(self):
return self.name
class Meta:
2021-01-19 23:43:43 +00:00
verbose_name_plural = "people"
2021-01-19 03:51:22 +00:00
class Quote(models.Model):
quote = models.TextField(null=False, blank=False)
added_by = models.ForeignKey(auth_models.User, on_delete=models.SET_NULL, null=True)
added_at = models.DateTimeField(default=datetime.datetime.now)
references = models.ManyToManyField(Person)
def __str__(self):
return self.quote