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