aboutsummaryrefslogtreecommitdiffstats
path: root/notice/models.py
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-04-22 09:26:48 +0800
committerWeitian LI <liweitianux@gmail.com>2014-04-22 09:26:48 +0800
commitb35eca8c38f89af8b30035a973f1edfba416eff6 (patch)
treeb1551b2a2e71b0e0753ae59572e1edfb629c753f /notice/models.py
parent7b9c7d04ba8080910dbf2b733685b3ed27fef6cc (diff)
downloaddjango-skaschool-b35eca8c38f89af8b30035a973f1edfba416eff6.tar.bz2
* added GenericRelation attachments field to 'Notice' model
* removed 'demo.urls' from urls.py
Diffstat (limited to 'notice/models.py')
-rw-r--r--notice/models.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/notice/models.py b/notice/models.py
index 469ad07..af2e648 100644
--- a/notice/models.py
+++ b/notice/models.py
@@ -3,7 +3,7 @@
from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
-from django.contrib.contenttypes.generic import GenericForeignKey
+from django.contrib.contenttypes import generic
from django.utils.translation import ugettext_lazy as _
@@ -17,7 +17,8 @@ class Notice(models.Model):
publisher = models.ForeignKey(User, verbose_name=_("Publisher"))
is_important = models.BooleanField(_("Is important"), default=False)
contents = models.TextField(_("Contents"))
- # NoticeAttachments to deal with attachments
+ # NoticeAttachment to deal with attachments
+ attachments = generic.GenericRelation('NoticeAttachment')
class Meta:
verbose_name = _('notice')
@@ -46,8 +47,8 @@ class NoticeCategory(models.Model):
class NoticeAttachment(models.Model):
attachment = models.FileField(upload_to='notice/attachments',
verbose_name=_("Attachment"))
- content_type = models.ForeignKey(ContentType, verbose_name=_("Content type"))
- object_id = models.PositiveIntegerField(_("Object ID"))
- content_object = GenericForeignKey("content_type", "object_id")
+ content_type = models.ForeignKey(ContentType)
+ object_id = models.PositiveIntegerField()
+ content_object = generic.GenericForeignKey("content_type", "object_id")