# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.
#分类表
class Category(models.Model):
    cno = models.AutoField(primary_key=True)
    cname = models.CharField(max_length=30,unique=True,verbose_name='分类名称')
    class Meta:
        db_table = 't_category'
    def __unicode__(self):
        return self.cname
#标签表
class Tag(models.Model):
    tno = models.AutoField(primary_key=True)
    tname = models.CharField(max_length=30,unique=True,verbose_name='标签名')
    class Meta:
        db_table = 't_tag'
    def __unicode__(self):
        return self.tname
#帖子内容表
class Post(models.Model):
    pno = models.AutoField(primary_key=True)
    title = models.CharField(max_length=100,verbose_name='帖子标题')
    des = models.TextField(verbose_name='帖子的描述')
    content = models.TextField(verbose_name='帖子的内容')
    publish_time = models.DateTimeField(auto_now_add=True,verbose_name='帖子发布的时间')
    category = models.ForeignKey(Category,on_delete=models.CASCADE,verbose_name='帖子的分类')
    tag = models.ManyToManyField(Tag,verbose_name='帖子的标签')
    class Meta:
        db_table = 't_post'
    def __unicode__(self):
        return self.title