#9104: FieldDoesNotExist is defined in "confusing" place.
-------------------------------------+-------------------------------------
     Reporter:  telenieko            |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  master
    Component:  Core (Other)         |               Resolution:
     Severity:  Normal               |             Triage Stage:  Design
     Keywords:                       |  decision needed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by wraus):

 * status:  closed => new
 * resolution:  needsinfo =>


Comment:

 I'd like to reopen this just to hopefully have this oddity resolved.

 One of the comments was talking about use cases, and I wanted to give the
 use case that I'm using for it to hopefully sway opinion a bit on making
 this simple change.

 I'm working on a template tag that will allow me to iterate over a list of
 a model's fields / attributes and output it as a table. I want to grab the
 verbose_name of the field, given the field's name, and to do so, I get
 obj._meta.get_field(field_name). However, I also want the option to
 reference class attributes and functions, and obviously if I reference a
 function or attribute, there is no matching field. Thus, I need to call
 get_field, and catch FieldDoesNotExist to handle it as a function /
 attribute and get a separate label.

 There doesn't seem to be a more "obvious" way to do this, and I ran into
 the issue of trying to find this oddly placed exception. I understand that
 moving the exception would be a serious change, but hopefully making it
 importable via django.core.exceptions will resolve this inconvenience.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/9104#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.67a1f98e18bc8a0ea6de793626635eb3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to