from django.db import models
from django.contrib.auth.models import User

class blogcategory(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name



class blogentry(models.Model):
    user = models.ForeignKey(User)
    date = models.DateTimeField('date')
    header = models.CharField(max_length=100)
    intro = models.CharField(max_length=1000)
    body = models.CharField(max_length=10000)
    categories = models.ManyToManyField('blogcategory')
    published = models.BooleanField(default=False)

    def __str__(self):
        return self.header

class blogcomment(models.Model):
    blogentry = models.ForeignKey(blogentry, on_delete=models.CASCADE)
    user = models.ForeignKey(User, null = True)
    guestname = models.CharField(max_length=20)
    body = models.CharField(max_length=300)
    date = models.DateTimeField('date')
