from django.db import models

from django.contrib.auth.models import User

# Create your models here.

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

    def __str__(self):
        return self.name

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

#    def __str__(self):
#        return self.name

class Post(models.Model) :
    title = models.CharField(max_length = 100)  #blog title
    date_time = models.DateTimeField(auto_now_add = True)  #blog time
    content = models.TextField(blank = True, null = True)  #blog content

    created_time = models.DateTimeField(auto_now_add=True)
    modified_time = models.DateTimeField(auto_now=True)

    category = models.ForeignKey(Category)
#    tags = models.ManyToManyField(Tag, blank=True)
    author = models.ForeignKey(User)


    def __str__(self) :
        return self.title

    class Meta:
        ordering = ['-created_time']
