]> gitweb.fperrin.net Git - djsite.git/blobdiff - quotes/models.py
Add the possibility of attaching notes to an author
[djsite.git] / quotes / models.py
index 71a836239075aa6e6e4ecb700e9c42c95c022d91..53afcbe246a20f61e2c1c03767de029739540fca 100644 (file)
@@ -1,3 +1,30 @@
 from django.db import models
 
 # Create your models here.
+
+class Author(models.Model):
+    name = models.CharField(max_length=100)
+    notes = models.TextField(blank=True, help_text= \
+                             "Notes for the author; may be left blank. Will \
+                              not be HTML-escaped.")
+
+    def __unicode__(self):
+        return self.name
+
+class Tag(models.Model):
+    tag = models.CharField(max_length=100)
+
+    def __unicode__(self):
+        return self.tag
+
+    class Meta:
+        ordering = ("tag", )
+
+class Quote(models.Model):
+    text = models.TextField()
+    author = models.ForeignKey(Author)
+    tags = models.ManyToManyField(Tag, blank=True)
+
+    def __unicode__(self):
+        return self.author.name + ": " + self.text
+