mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	git-svn-id: http://code.djangoproject.com/svn/django/trunk@10499 bcc190cf-cafb-0310-a4f2-bffc1f526a37
		
			
				
	
	
		
			39 lines
		
	
	
		
			935 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			935 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from django.db import models
 | |
| 
 | |
| try:
 | |
|     import decimal
 | |
| except ImportError:
 | |
|     from django.utils import _decimal as decimal    # Python 2.3 fallback
 | |
| 
 | |
| class Foo(models.Model):
 | |
|     a = models.CharField(max_length=10)
 | |
|     d = models.DecimalField(max_digits=5, decimal_places=3)
 | |
| 
 | |
| 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)
 | |
| 
 | |
| class Whiz(models.Model):
 | |
|     CHOICES = (
 | |
|         ('Group 1', (
 | |
|                 (1,'First'),
 | |
|                 (2,'Second'),
 | |
|             )
 | |
|         ),
 | |
|         ('Group 2', (
 | |
|                 (3,'Third'),
 | |
|                 (4,'Fourth'),
 | |
|             )
 | |
|         ),
 | |
|         (0,'Other'),
 | |
|     )
 | |
|     c = models.IntegerField(choices=CHOICES, null=True)
 | |
|     
 | |
| class BigD(models.Model):
 | |
|     d = models.DecimalField(max_digits=38, decimal_places=30)
 | |
| 
 | |
| class BigS(models.Model):
 | |
|     s = models.SlugField(max_length=255) |