from todo.models import *
from django.contrib import admin
import datetime
# Create your models here.
class List(models.Model):
name = models.CharField(max_length = 60)
slug = models.SlugField(max_length = 60,editable = False)
#group =models.ForeignKey(Group)
def __unicode__(self):
return self.name
class Meta:
ordering = ["name"]
verbose_name_plural ="Lists"
#Prevents (at the db level) creation of two lists with the same name in the same group
class Item(models.Model):
title = models.CharField(max_length = 150)
list = models.ForeignKey(List)
created_date = models.DateField(auto_now = True,auto_now_add = True)
due_date = models.DateField(blank = True,null = True)
completed = models.BooleanField()
completed_date = models.DateField(blank =True,null = True)
#creted_by = models.ForeignKey(User,related_name = 'todo_created_by')
#assigned_to = models.ForeignKey(User,related_name = 'todo_assigned_to')
note = models.TextField(blank = True,null = True)
priority = models.PositiveIntegerField(max_length = 5)
def __unicode__(self):
return self.title
class Meta:
ordering = ["priority"]
class Comment(models.Model):
"""Not using Django's build-in comment because we wang=t to be able to save a comment and change task details at the same time ,Roling our own since it's easy ."""
#author = models.ForeignKey(User)
task = models.ForeignKey(Item)
date = models.DateTimeField(default = datetime.datetime.now)
body = models.TextField(blank =True)
def __unicode__(self):
return '%s-%s' %(self.author,self.date,)
ubuntu下python3.4+django创建网站
最新推荐文章于 2023-03-27 17:11:17 发布
本文介绍了一个基于Django框架实现的任务列表应用模型设计,包括任务列表、任务项及评论模型。任务列表可以拥有多个任务项,每个任务项记录了创建日期、截止日期、完成状态等详细信息。

1580

被折叠的 条评论
为什么被折叠?



