BBS website models#!/usr/bin/env python#_*_coding:utf-8_*_from django.db import Modelsfrom 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.titleclass Category (models. Model): name = models. Charfield (max_length=64,unique=true) admins = models. Manytomanyfield (' userprofile ') def __unicode__ (self): return Self.nameclass Thumbup (models. Model): Article = models. ForeignKey (' article ') user = models. ForeignKey (' userprofile ') date = models. Datetimefield (auto_now_add=true) def __unicode__ (self): return Self.articleclasS UserProfile (models. Model): User = models. Onetoonefield (User) name = models. Charfield (max_length=32) user_groups = models. Manytomanyfield (' UserGroup ') def __unicode__ (self): return Self.nameclass UserGroup (models. Model): name = models. Charfield (max_length=64,unique=true) def __unicode__ (self): return Self.nameclass 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 website Models