Opened 8 years ago

Closed 8 years ago

#9105 closed (wontfix)

__unicode__ method for models

Reported by: guettli 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: UI/UX:



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 guettli 8 years ago.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by guettli

comment:1 Changed 8 years ago by mattmcc

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 8 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from new to closed

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