Opened 12 years ago

Closed 12 years ago

#18848 closed Cleanup/optimization (wontfix)

model/presentation separation — at Version 1

Reported by: yaoheling@… 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 (last modified by Karen Tracey)

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

Change History (1)

comment:1 by Karen Tracey, 12 years ago

Description: modified (diff)
Resolution: wontfix
Status: newclosed

Thanks for the suggestion. If we had to do it all over again, possibly we'd come up with a scheme where there admin-only stuff was not hung somewhat arbitrarily off of model methods. However at this point we cannot remove support for this way of doing it without massive backwards-incompatibility. And adding a "cleaner" way without removing the old way would, I think, be more confusing than helpful.

Note: See TracTickets for help on using tickets.
Back to Top