2017-02-07 04:49:31 +00:00
|
|
|
import datetime
|
|
|
|
import uuid
|
|
|
|
from decimal import Decimal
|
|
|
|
|
2011-09-09 19:22:28 +00:00
|
|
|
from django.db import models
|
2017-02-07 04:49:31 +00:00
|
|
|
from django.utils import timezone
|
2011-09-09 19:22:28 +00:00
|
|
|
|
2017-02-13 13:58:10 +00:00
|
|
|
try:
|
|
|
|
from PIL import Image
|
|
|
|
except ImportError:
|
|
|
|
Image = None
|
|
|
|
|
2011-09-09 19:22:28 +00:00
|
|
|
|
|
|
|
class Country(models.Model):
|
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
iso_two_letter = models.CharField(max_length=2)
|
2017-02-24 15:54:10 +00:00
|
|
|
description = models.TextField()
|
2011-09-09 19:22:28 +00:00
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2015-06-18 14:12:07 +00:00
|
|
|
class ProxyCountry(Country):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
|
|
|
|
|
|
|
class ProxyProxyCountry(ProxyCountry):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
|
|
|
|
|
|
|
class ProxyMultiCountry(ProxyCountry):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ProxyMultiProxyCountry(ProxyMultiCountry):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
|
|
|
|
2011-09-09 19:22:28 +00:00
|
|
|
class Place(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2011-09-09 19:22:28 +00:00
|
|
|
class Restaurant(Place):
|
|
|
|
pass
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2011-09-09 19:22:28 +00:00
|
|
|
class Pizzeria(Restaurant):
|
|
|
|
pass
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2011-09-09 19:22:28 +00:00
|
|
|
class State(models.Model):
|
2012-04-29 01:22:05 +00:00
|
|
|
two_letter_code = models.CharField(max_length=2, primary_key=True)
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2012-04-29 01:22:05 +00:00
|
|
|
class TwoFields(models.Model):
|
|
|
|
f1 = models.IntegerField(unique=True)
|
|
|
|
f2 = models.IntegerField(unique=True)
|
2015-10-09 01:14:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class NoFields(models.Model):
|
|
|
|
pass
|
2017-02-07 04:49:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class NullableFields(models.Model):
|
|
|
|
# Fields in db.backends.oracle.BulkInsertMapper
|
|
|
|
big_int_filed = models.BigIntegerField(null=True, default=1)
|
|
|
|
binary_field = models.BinaryField(null=True, default=b'data')
|
|
|
|
date_field = models.DateField(null=True, default=timezone.now)
|
|
|
|
datetime_field = models.DateTimeField(null=True, default=timezone.now)
|
|
|
|
decimal_field = models.DecimalField(null=True, max_digits=2, decimal_places=1, default=Decimal('1.1'))
|
|
|
|
duration_field = models.DurationField(null=True, default=datetime.timedelta(1))
|
|
|
|
float_field = models.FloatField(null=True, default=3.2)
|
|
|
|
integer_field = models.IntegerField(null=True, default=2)
|
|
|
|
null_boolean_field = models.NullBooleanField(null=True, default=False)
|
|
|
|
positive_integer_field = models.PositiveIntegerField(null=True, default=3)
|
|
|
|
positive_small_integer_field = models.PositiveSmallIntegerField(null=True, default=4)
|
|
|
|
small_integer_field = models.SmallIntegerField(null=True, default=5)
|
|
|
|
time_field = models.TimeField(null=True, default=timezone.now)
|
|
|
|
# Fields not required in BulkInsertMapper
|
|
|
|
char_field = models.CharField(null=True, max_length=4, default='char')
|
|
|
|
email_field = models.EmailField(null=True, default='user@example.com')
|
|
|
|
file_field = models.FileField(null=True, default='file.txt')
|
|
|
|
file_path_field = models.FilePathField(path='/tmp', null=True, default='file.txt')
|
|
|
|
generic_ip_address_field = models.GenericIPAddressField(null=True, default='127.0.0.1')
|
2017-02-13 13:58:10 +00:00
|
|
|
if Image:
|
|
|
|
image_field = models.ImageField(null=True, default='image.jpg')
|
2017-02-07 04:49:31 +00:00
|
|
|
slug_field = models.SlugField(null=True, default='slug')
|
|
|
|
text_field = models.TextField(null=True, default='text')
|
|
|
|
url_field = models.URLField(null=True, default='/')
|
|
|
|
uuid_field = models.UUIDField(null=True, default=uuid.uuid4)
|