2008-03-20 14:56:23 +08:00
|
|
|
from django.db import models
|
|
|
|
|
2008-07-30 08:18:49 +08:00
|
|
|
try:
|
|
|
|
import decimal
|
|
|
|
except ImportError:
|
|
|
|
from django.utils import _decimal as decimal # Python 2.3 fallback
|
|
|
|
|
2008-03-20 14:56:23 +08:00
|
|
|
class Foo(models.Model):
|
|
|
|
a = models.CharField(max_length=10)
|
2008-07-30 08:18:49 +08:00
|
|
|
d = models.DecimalField(max_digits=5, decimal_places=3)
|
2008-03-20 14:56:23 +08:00
|
|
|
|
|
|
|
def get_foo():
|
|
|
|
return Foo.objects.get(id=1)
|
|
|
|
|
|
|
|
class Bar(models.Model):
|
|
|
|
b = models.CharField(max_length=10)
|
|
|
|
a = models.ForeignKey(Foo, default=get_foo)
|
|
|
|
|
2008-07-27 15:22:39 +08:00
|
|
|
class Whiz(models.Model):
|
|
|
|
CHOICES = (
|
|
|
|
('Group 1', (
|
|
|
|
(1,'First'),
|
|
|
|
(2,'Second'),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
('Group 2', (
|
|
|
|
(3,'Third'),
|
|
|
|
(4,'Fourth'),
|
|
|
|
)
|
2008-07-30 08:18:49 +08:00
|
|
|
),
|
2008-07-27 15:22:39 +08:00
|
|
|
(0,'Other'),
|
|
|
|
)
|
|
|
|
c = models.IntegerField(choices=CHOICES, null=True)
|
2008-11-12 08:35:24 +08:00
|
|
|
|
|
|
|
class BigD(models.Model):
|
|
|
|
d = models.DecimalField(max_digits=38, decimal_places=30)
|
2008-07-30 08:18:49 +08:00
|
|
|
|
2008-12-03 02:40:40 +08:00
|
|
|
class BigS(models.Model):
|
2009-04-11 03:54:14 +08:00
|
|
|
s = models.SlugField(max_length=255)
|