2010-01-10 03:36:59 +00:00
|
|
|
from django.db import models
|
2012-07-20 12:48:51 +00:00
|
|
|
from django.utils import six
|
2012-08-12 10:32:08 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2010-01-10 03:36:59 +00:00
|
|
|
|
2011-10-13 18:51:33 +00:00
|
|
|
|
2014-12-23 17:43:55 +00:00
|
|
|
@python_2_unicode_compatible
|
|
|
|
class Site(models.Model):
|
|
|
|
domain = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.domain
|
|
|
|
|
|
|
|
|
2010-01-10 03:36:59 +00:00
|
|
|
class Article(models.Model):
|
|
|
|
"""
|
|
|
|
A simple Article model for testing
|
|
|
|
"""
|
2015-07-22 14:43:21 +00:00
|
|
|
site = models.ForeignKey(Site, models.CASCADE, related_name="admin_articles")
|
2010-01-10 03:36:59 +00:00
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
title2 = models.CharField(max_length=100, verbose_name="another name")
|
|
|
|
created = models.DateTimeField()
|
|
|
|
|
|
|
|
def test_from_model(self):
|
|
|
|
return "nothing"
|
|
|
|
|
|
|
|
def test_from_model_with_override(self):
|
|
|
|
return "nothing"
|
2010-04-11 08:35:04 +00:00
|
|
|
test_from_model_with_override.short_description = "not What you Expect"
|
2010-02-26 13:17:43 +00:00
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 13:17:43 +00:00
|
|
|
class Count(models.Model):
|
|
|
|
num = models.PositiveSmallIntegerField()
|
2015-07-22 14:43:21 +00:00
|
|
|
parent = models.ForeignKey('self', models.CASCADE, null=True)
|
2010-11-09 16:46:42 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2012-07-20 12:48:51 +00:00
|
|
|
return six.text_type(self.num)
|
2010-10-17 15:17:52 +00:00
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2010-10-17 15:17:52 +00:00
|
|
|
class Event(models.Model):
|
|
|
|
date = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2010-10-17 15:17:52 +00:00
|
|
|
class Location(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
event = models.OneToOneField(Event, models.CASCADE, verbose_name='awesome event')
|
2010-10-17 15:17:52 +00:00
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2010-10-17 15:17:52 +00:00
|
|
|
class Guest(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
event = models.OneToOneField(Event, models.CASCADE)
|
2010-10-17 15:17:52 +00:00
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = "awesome guest"
|
2012-09-20 15:51:30 +00:00
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2012-09-20 15:51:30 +00:00
|
|
|
class EventGuide(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
event = models.ForeignKey(Event, models.DO_NOTHING)
|
2014-01-21 17:25:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Vehicle(models.Model):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class VehicleMixin(Vehicle):
|
2015-07-22 14:43:21 +00:00
|
|
|
vehicle = models.OneToOneField(
|
|
|
|
Vehicle,
|
|
|
|
models.CASCADE,
|
|
|
|
parent_link=True,
|
|
|
|
related_name='vehicle_%(app_label)s_%(class)s',
|
|
|
|
)
|
2014-01-21 17:25:33 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
|
|
|
|
|
|
|
class Car(VehicleMixin):
|
|
|
|
pass
|