Opened 16 years ago

Closed 16 years ago

#9105 closed (wontfix)

__unicode__ method for models

Reported by: Thomas Güttler Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords:
Cc: hv@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

Here is small patch to give models a __unicode__ method which includes
its primary key and class name.

Every time I create a new model and look into the admin page (/admin/myapp/mymodel/) I
see a list of:

  • MyModel object
  • MyModel object
  • MyModel object

It would be better to have

  • MyModel 1
  • MyModel 2
  • ....

Attachments (1)

model__unicode__method.diff (779 bytes ) - added by Thomas Güttler 16 years ago.

Download all attachments as: .zip

Change History (3)

by Thomas Güttler, 16 years ago

Attachment: model__unicode__method.diff added

comment:1 by Matt McClanahan, 16 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Malcolm Tredinnick, 16 years ago

Resolution: wontfix
Status: newclosed

No, this is contrary to how Python normally behaves. You don't get a string-form for free apart form repr() on classes. If you want something different, you define the right method. "Be like Python" is a pretty good guide for this sort of thing. The current default is actually pretty useful: it guides people to immediately think about what they want to have as the default string representation for their particular model.

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