2021-01-14 00:19:22 +08:00
|
|
|
from django.contrib import admin
|
2010-01-10 11:36:59 +08:00
|
|
|
from django.db import models
|
2017-01-27 03:58:33 +08:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2010-01-10 11:36:59 +08:00
|
|
|
|
2011-10-14 02:51:33 +08:00
|
|
|
|
2014-12-24 01:43:55 +08:00
|
|
|
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
|
|
|
|
"""
|
2022-02-04 03:24:19 +08:00
|
|
|
|
2015-07-22 22:43:21 +08:00
|
|
|
site = models.ForeignKey(Site, models.CASCADE, related_name="admin_articles")
|
2010-01-10 11:36:59 +08:00
|
|
|
title = models.CharField(max_length=100)
|
2020-06-25 17:23:26 +08:00
|
|
|
hist = models.CharField(
|
|
|
|
max_length=100,
|
|
|
|
verbose_name=_("History"),
|
|
|
|
help_text=_("History help text"),
|
|
|
|
)
|
2015-12-27 02:51:22 +08:00
|
|
|
created = models.DateTimeField(null=True)
|
2010-01-10 11:36:59 +08:00
|
|
|
|
2017-06-10 00:36:09 +08:00
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
2010-01-10 11:36:59 +08:00
|
|
|
def test_from_model(self):
|
|
|
|
return "nothing"
|
|
|
|
|
2021-01-14 00:19:22 +08:00
|
|
|
@admin.display(description="not What you Expect")
|
2010-01-10 11:36:59 +08:00
|
|
|
def test_from_model_with_override(self):
|
|
|
|
return "nothing"
|
2010-02-26 21:17:43 +08:00
|
|
|
|
2013-11-03 12:36:09 +08:00
|
|
|
|
2015-12-27 01:46:51 +08:00
|
|
|
class ArticleProxy(Article):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class Count(models.Model):
|
|
|
|
num = models.PositiveSmallIntegerField()
|
2015-07-22 22:43:21 +08:00
|
|
|
parent = models.ForeignKey("self", models.CASCADE, null=True)
|
2010-11-10 00:46:42 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2016-12-29 23:27:49 +08:00
|
|
|
return str(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):
|
2015-07-22 22:43:21 +08:00
|
|
|
event = models.OneToOneField(Event, models.CASCADE, verbose_name="awesome event")
|
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 Guest(models.Model):
|
2015-07-22 22:43:21 +08:00
|
|
|
event = models.OneToOneField(Event, models.CASCADE)
|
2010-10-17 23:17:52 +08:00
|
|
|
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):
|
2015-07-22 22:43:21 +08:00
|
|
|
event = models.ForeignKey(Event, models.DO_NOTHING)
|
2014-01-22 01:25:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
class Vehicle(models.Model):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class VehicleMixin(Vehicle):
|
2015-07-22 22:43:21 +08:00
|
|
|
vehicle = models.OneToOneField(
|
|
|
|
Vehicle,
|
|
|
|
models.CASCADE,
|
|
|
|
parent_link=True,
|
|
|
|
related_name="vehicle_%(app_label)s_%(class)s",
|
|
|
|
)
|
2014-01-22 01:25:33 +08:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
|
|
|
|
|
|
|
class Car(VehicleMixin):
|
|
|
|
pass
|