Opened 12 years ago
Last modified 12 years ago
#18848 closed Cleanup/optimization
model/presentation separation — at Initial Version
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.4 |
Severity: | Normal | Keywords: | models.Model, admin.ModelAdmin |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm working through the tutorial and noticed the following snippet:
class Poll(models.Model):
# ...
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'
All 3 attributes admin_order_field, boolean, and short_description seem to be related to how was_published_recently is presented in the admin interface. I guess there might be other such attributes in models.Model as well.
Maybe such attributes should be moved to admin.ModelAdmin?
Thanks,
Heling