summaryrefslogtreecommitdiff
path: root/blog/models.py
diff options
context:
space:
mode:
authorMark Weiman <mark.weiman@markzz.com>2015-10-11 01:00:38 -0400
committerMark Weiman <mark.weiman@markzz.com>2015-10-11 01:00:38 -0400
commit57aa89824a8dabb631c15af986a39e779d0fe3cb (patch)
tree2df3bf79026e1c544e57375566297bcc7634afa5 /blog/models.py
downloadwebsite-57aa89824a8dabb631c15af986a39e779d0fe3cb.tar.gz
website-57aa89824a8dabb631c15af986a39e779d0fe3cb.zip
inital
Diffstat (limited to 'blog/models.py')
-rw-r--r--blog/models.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/blog/models.py b/blog/models.py
new file mode 100644
index 0000000..335be37
--- /dev/null
+++ b/blog/models.py
@@ -0,0 +1,32 @@
+from django.db import models
+from django.utils.encoding import smart_text
+from django.contrib.auth.models import User
+
+# Create your models here.
+
+
+class Post(models.Model):
+ # model for your simple blog post
+ title = models.CharField(max_length=255, blank=False, null=False)
+ body = models.TextField(blank=False, null=False)
+ header_image = models.CharField(max_length=255, blank=False, null=False, default='&black')
+ user = models.ForeignKey(User, blank=False, null=False)
+ created = models.DateTimeField(blank=False, null=False)
+ edited = models.DateTimeField(blank=True, null=True)
+ comments_enabled = models.BooleanField(blank=False, null=False, default=False)
+
+ def __str__(self):
+ return smart_text("%s" % (self.title,))
+
+
+class Comment(models.Model):
+ # model for comments on a post
+ # will not be shown if Post.comments_enabled is False
+ name = models.CharField(max_length=255, blank=False, null=False)
+ email = models.EmailField(null=False, blank=False)
+ timestamp = models.DateTimeField(blank=False, null=False)
+ post = models.ForeignKey(Post, blank=False, null=False)
+ comment = models.TextField(blank=False, null=False)
+
+ def __str__(self):
+ return smart_text("%s - %s" % (self.post.id, self.comment[:50],))