equal
deleted
inserted
replaced
|
1 import datetime |
|
2 from django.db import models |
|
3 from django.utils.translation import ugettext_lazy as _ |
|
4 |
|
5 def standalone_number(self): |
|
6 return 1 |
|
7 |
|
8 class Numbers(object): |
|
9 @staticmethod |
|
10 def get_static_number(self): |
|
11 return 2 |
|
12 |
|
13 @classmethod |
|
14 def get_class_number(self): |
|
15 return 3 |
|
16 |
|
17 def get_member_number(self): |
|
18 return 4 |
|
19 |
|
20 nn = Numbers() |
|
21 |
|
22 class Group(models.Model): |
|
23 name = models.CharField(_('name'), max_length=100) |
|
24 |
|
25 class Event(models.Model): |
|
26 group = models.ForeignKey(Group) |
|
27 |
|
28 class Happening(models.Model): |
|
29 when = models.DateTimeField(blank=True, default=datetime.datetime.now) |
|
30 name = models.CharField(blank=True, max_length=100, default=lambda:"test") |
|
31 number1 = models.IntegerField(blank=True, default=standalone_number) |
|
32 number2 = models.IntegerField(blank=True, default=Numbers.get_static_number) |
|
33 number3 = models.IntegerField(blank=True, default=Numbers.get_class_number) |
|
34 number4 = models.IntegerField(blank=True, default=nn.get_member_number) |