from django db import models from datetime import datetime class News

 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
42
43
44
45
46
47
48
49
50
from django.db import models
from datetime import datetime
class News(models.Model):
title = models.CharField(max_length=50)
content = models.TextField()
date = models.DateField(editable=False)
active = models.BooleanField(blank=True)
category = models.ForeignKey('Sections')
def __unicode__(self):
return self.title
def save(self):
self.date = datetime.today()
super(News,self).save()
class Admin:
list_display = ('title','date','active')
class Meta:
verbose_name = _('News')
verbose_name_plural = _('News')
class Page(models.Model):
name = models.CharField(max_length=20)
def __unicode__(self):
return self.name
class Admin:
list_display = ('name',)
class Sections(models.Model):
name = models.CharField(max_length=30)
display_name = models.CharField(max_length=30)
path = models.CharField(max_length=50)
class Admin:
list_display = ('name','path')
class Meta:
verbose_name = 'Sections'
verbose_name_plural = 'Sections'
def __unicode__(self):
return self.name