BBS website Models

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.