1 from django
.db
import models
2 from django
.contrib
.auth
.models
import User
5 class News(models
.Model
):
6 id = models
.AutoField(primary_key
=True)
7 author
= models
.ForeignKey(User
)
8 postdate
= models
.DateField(auto_now_add
=True)
9 title
= models
.CharField(maxlength
=255)
10 content
= models
.TextField()
13 verbose_name_plural
= 'news'
14 get_latest_by
= 'postdate'
15 ordering
= ['-postdate', '-id']
17 def get_absolute_url(self
):
18 return '/news/%i/' % self
.id
20 # vim: set ts=4 sw=4 et: