class Event(
OwnedModelMixin,
TimeStampedModelMixin,
RandomIDMixin,
models.Model,
):
after_sunset = models.BooleanField(default=False)
date = models.DateField(blank=True, null=True)
notes = models.TextField(blank=True, default="")
is_published = models.BooleanField(default=False)
is_public = models.BooleanField(default=False)
shabbos = models.BooleanField(default=False)
starts = models.TimeField(blank=True, null=True)
venue = models.ForeignKey(Venue, editable=False, blank=True, null=True)
community = models.ForeignKey(Community, blank=True, null=True)
def __str__(self): # pragma: no cover
"""
Returns a reprsenative fields depending on the event type
"""
child_events = (
'bar_mitzvah',
'bar_mitzvah_kiddush',
'bris',
'kiddush',
'shalom_zochor',
'vachnacht',
)
if self.event_type in child_events:
return '{} on {},is_published: {}'.format(
self.event_type,
self.date,
self.is_published
)
else:
return '{} on {},is_published: {}'.format(
self.event_type,
self.date,
self.is_published
)
有近160个属性我没有包含在其中。但是所有属性都不是一直需要的。我想延迟加载这些属性以提高性能。由于有160个属性,有1000行。我怎么能?