#21563: calling hasattr(model_instance, fieldname) raises DoesNotExist when 
False
-------------------------------------+-------------------------------------
     Reporter:  monkut               |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  1.6
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Accepted
     Severity:  Normal               |      Needs documentation:  0
     Keywords:                       |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by charettes):

 Replying to [comment:3 aaugustin]:

 > It could be preferrable to define `RelatedObjectDoesNotExist` similarly
 for the forwards and backwards relations. Is there a downside to using a
 cached property for both? I value consistency a lot in this area of the
 code base, for reasons that must be obvious to you by now ;-) Once you've
 considered this question, ship it!

 No objection to use a `cached_property` in both cases.

 I kept the one created at initialization time since I felt like the
 `cached_property` approach was kind of ''hackish'', hence the
 `ReverseSingleRelatedObjectDescriptor`
 
[https://github.com/charettes/django/commit/6a83d41c38e01e0aecbd1e90ca4aa36f10b0925d
 #diff-3010fc5a498b7171c342520f34507968R266 comment].

 I'll add a comment to explain
 `SingleRelatedObjectDescriptor.RelatedObjectDoesNotExist` is also a
 `cached_property` for the sake of consistency.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21563#comment:4>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.1631c07bc7fceffa9a596a8a3d610aa5%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to