| author | ymh <ymh.work@gmail.com> |
| Mon, 01 Feb 2010 14:54:05 +0100 | |
| changeset 21 | 28c536d35d6e |
| parent 3 | 526ebd3988b0 |
| permissions | -rw-r--r-- |
|
3
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
""" |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
Django Extensions abstract base model classes. |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
""" |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
|
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
from django.db import models |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
from django.utils.translation import ugettext_lazy as _ |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
from django_extensions.db.fields import (ModificationDateTimeField, |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
CreationDateTimeField, AutoSlugField) |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
|
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
class TimeStampedModel(models.Model): |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
""" TimeStampedModel |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
An abstract base class model that provides self-managed "created" and |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
"modified" fields. |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
""" |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
created = CreationDateTimeField(_('created')) |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
modified = ModificationDateTimeField(_('modified')) |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
|
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
class Meta: |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
abstract = True |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
|
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
class TitleSlugDescriptionModel(models.Model): |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
""" TitleSlugDescriptionModel |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
An abstract base class model that provides title and description fields |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
and a self-managed "slug" field that populates from the title. |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
""" |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
title = models.CharField(_('title'), max_length=255) |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
slug = AutoSlugField(_('slug'), populate_from='title') |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
description = models.TextField(_('description'), blank=True, null=True) |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
|
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
class Meta: |
|
526ebd3988b0
replace pocketfilms occurence by blinkster
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
abstract = True |