标签:
bbs网站 models #!/usr/bin/env python #_*_coding:utf-8_*_ from django.db import models from django.contrib.auth.models import User # Create your models here. class Article(models.Model): title = models.CharField(max_length=254) category = models.ForeignKey(‘Category‘) conetent = models.TextField(max_length=100000) author = models.ForeignKey(‘UserProfile‘) publish_date = models.DateTimeField(auto_now_add=True) summary = models.TextField(max_length=256) #thumb_ups = models.ForeignKey(‘ThumbUp‘,blank=True) #comments = models.ManyToManyField(‘Comments‘,blank=True) #head_image = models.ImageField() def __unicode__(self): return self.title class Category(models.Model): name = models.CharField(max_length=64,unique=True) admins = models.ManyToManyField(‘UserProfile‘) def __unicode__(self): return self.name class ThumbUp(models.Model): article = models.ForeignKey(‘Article‘) user = models.ForeignKey(‘UserProfile‘) date = models.DateTimeField(auto_now_add=True) def __unicode__(self): return self.article class UserProfile(models.Model): user = models.OneToOneField(User) name = models.CharField(max_length=32) user_groups = models.ManyToManyField(‘UserGroup‘) def __unicode__(self): return self.name class UserGroup(models.Model): name = models.CharField(max_length=64,unique=True) def __unicode__(self): return self.name class Comments(models.Model): article = models.ForeignKey(‘Article‘) user = models.ForeignKey(‘UserProfile‘) parent_comment = models.ForeignKey(‘Comments‘,blank=True,null=True,related_name=‘pid‘) comment = models.TextField(max_length=1024,) date = models.DateTimeField(auto_now_add=True) def __unicode__(self): return self.article.comments标签:
原文地址:http://www.cnblogs.com/fengjian2016/p/5413222.html