coding utf-8 from django db import models from django dispatch import

 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
# -*- coding:utf-8 -*-
from django.db import models
from django.dispatch import dispatcher
from django.db.models import signals
from marks.libs.signals import add_mark_for_author
from tagging.fields import TagField
# Create your models here.
class Author(models.Model):
login = models.CharField(max_length=32)
date_first_mark = models.DateTimeField('date first mark')
mark_count = models.IntegerField(default=0)
class Meta:
ordering = ['date_first_mark']
def __unicode__(self):
return self.login
class Admin:
pass
class mark(models.Model):
title = models.CharField(max_length=32)
content = models.TextField()
author = models.ForeignKey(Author)
review = models.IntegerField()
public = models.BooleanField(default=False)
date_add = models.DateTimeField('mark add')
tags = TagField()
def __unicode__(self):
return self.title
class Meta:
ordering = ['date_add']
class Admin:
pass
dispatcher.connect(add_mark_for_author, signal=signals.post_save, sender=mark)