2010-01-10 03:36:59 +00:00
|
|
|
from django.db import models
|
2017-01-26 19:58:33 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2010-01-10 03:36:59 +00:00
|
|
|
|
2011-10-13 18:51:33 +00:00
|
|
|
|
2014-12-23 17:43:55 +00:00
|
|
|
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)
|
2020-06-25 09:23:26 +00:00
|
|
|
hist = models.CharField(
|
|
|
|
max_length=100,
|
|
|
|
verbose_name=_('History'),
|
|
|
|
help_text=_('History help text'),
|
|
|
|
)
|
2015-12-26 18:51:22 +00:00
|
|
|
created = models.DateTimeField(null=True)
|
2010-01-10 03:36:59 +00:00
|
|
|
|
2017-06-09 16:36:09 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
2010-01-10 03:36:59 +00:00
|
|
|
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
|
|
|
|
2015-12-26 17:46:51 +00:00
|
|
|
class ArticleProxy(Article):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
|
|
|
|
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):
|
2016-12-29 15:27:49 +00:00
|
|
|
return str(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
|