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