码迷,mamicode.com
首页 > Web开发 > 详细

bbs网站 models

时间:2016-04-20 16:25:41      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

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

bbs网站 models

标签:

原文地址:http://www.cnblogs.com/fengjian2016/p/5413222.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!