2015-01-02 01:39:31 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2015-01-15 17:40:31 +00:00
|
|
|
try:
|
|
|
|
from PIL import Image
|
|
|
|
except ImportError:
|
|
|
|
Image = None
|
|
|
|
|
2015-01-02 01:39:31 +00:00
|
|
|
|
|
|
|
class CaseTestModel(models.Model):
|
|
|
|
integer = models.IntegerField()
|
|
|
|
integer2 = models.IntegerField(null=True)
|
|
|
|
string = models.CharField(max_length=100, default='')
|
|
|
|
|
|
|
|
big_integer = models.BigIntegerField(null=True)
|
|
|
|
binary = models.BinaryField(default=b'')
|
|
|
|
boolean = models.BooleanField(default=False)
|
|
|
|
date = models.DateField(null=True, db_column='date_field')
|
|
|
|
date_time = models.DateTimeField(null=True)
|
|
|
|
decimal = models.DecimalField(max_digits=2, decimal_places=1, null=True, db_column='decimal_field')
|
|
|
|
duration = models.DurationField(null=True)
|
|
|
|
email = models.EmailField(default='')
|
|
|
|
file = models.FileField(null=True, db_column='file_field')
|
|
|
|
file_path = models.FilePathField(null=True)
|
|
|
|
float = models.FloatField(null=True, db_column='float_field')
|
2015-01-15 17:40:31 +00:00
|
|
|
if Image:
|
|
|
|
image = models.ImageField(null=True)
|
2015-01-02 01:39:31 +00:00
|
|
|
generic_ip_address = models.GenericIPAddressField(null=True)
|
2017-05-06 14:56:28 +00:00
|
|
|
null_boolean = models.BooleanField(null=True)
|
2015-01-02 01:39:31 +00:00
|
|
|
positive_integer = models.PositiveIntegerField(null=True)
|
|
|
|
positive_small_integer = models.PositiveSmallIntegerField(null=True)
|
2019-10-16 12:32:12 +00:00
|
|
|
positive_big_integer = models.PositiveSmallIntegerField(null=True)
|
2015-01-02 01:39:31 +00:00
|
|
|
slug = models.SlugField(default='')
|
|
|
|
small_integer = models.SmallIntegerField(null=True)
|
|
|
|
text = models.TextField(default='')
|
|
|
|
time = models.TimeField(null=True, db_column='time_field')
|
|
|
|
url = models.URLField(default='')
|
|
|
|
uuid = models.UUIDField(null=True)
|
2015-07-22 14:43:21 +00:00
|
|
|
fk = models.ForeignKey('self', models.CASCADE, null=True)
|
2015-01-02 01:39:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class O2OCaseTestModel(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
o2o = models.OneToOneField(CaseTestModel, models.CASCADE, related_name='o2o_rel')
|
2015-01-02 01:39:31 +00:00
|
|
|
integer = models.IntegerField()
|
|
|
|
|
|
|
|
|
|
|
|
class FKCaseTestModel(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
fk = models.ForeignKey(CaseTestModel, models.CASCADE, related_name='fk_rel')
|
2015-01-02 01:39:31 +00:00
|
|
|
integer = models.IntegerField()
|
|
|
|
|
|
|
|
|
|
|
|
class Client(models.Model):
|
|
|
|
REGULAR = 'R'
|
|
|
|
GOLD = 'G'
|
|
|
|
PLATINUM = 'P'
|
|
|
|
ACCOUNT_TYPE_CHOICES = (
|
|
|
|
(REGULAR, 'Regular'),
|
|
|
|
(GOLD, 'Gold'),
|
|
|
|
(PLATINUM, 'Platinum'),
|
|
|
|
)
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
registered_on = models.DateField()
|
|
|
|
account_type = models.CharField(
|
|
|
|
max_length=1,
|
|
|
|
choices=ACCOUNT_TYPE_CHOICES,
|
|
|
|
default=REGULAR,
|
|
|
|
)
|