-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
41 lines (25 loc) · 972 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from django.db import models
from django.contrib.auth.models import User
# class User(models.Model):
# name = models.CharField(max_length=30)
# pwd = models.CharField(max_length=30)
# email = models.EmailField(blank=True)
# def __unicode__(self):
# return u'%s' % self.name
class Tag(models.Model):
tag_name = models.CharField(max_length=20, blank=True)
create_time = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return self.tag_name
class Blog(models.Model):
title = models.CharField(max_length=100)
user = models.ForeignKey(User)
tags = models.ManyToManyField(Tag, blank=True)
content = models.TextField()
published_time = models.DateTimeField(auto_now_add=True)
update_time = models.DateTimeField(auto_now=True)
class Meta:
ordering = ['-published_time']
def __unicode__(self):
return u'%s %s %s' % (self.title, self.user, self.published_time)
# Create your models here.