Comment (by Abhijeet Viswa):
I gave a shot at fixing this ticket. However, I got stuck real fast. F
expressions aren't resolved until the queryset is evaluated. However, the
test to check if the right-value is an instance of the forward relation's
class is performed during assignment. The only solution I could think of
is to defer the test for F expressions until queryset evaluation.
Maintainers, would this be the best approach?
--
Ticket URL: <https://code.djangoproject.com/ticket/11541#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Abhijeet Viswa (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/11541#comment:7>
Comment (by Simon Charette):
> The only solution I could think of is to defer the test for F
expressions until queryset evaluation.
Abhijeet, the check can likely be deferred `if hasattr(value,
resolve_expression)`.
--
Ticket URL: <https://code.djangoproject.com/ticket/11541#comment:8>
Comment (by Abhijeet Viswa):
Marten Kenbeek pointed out to me that `F`expression can be assigned to the
`attname` attribute of the Model instance. So,
`test_gmbh.point_of_contact_id` can be assigned `F('ceo')` to have the
intended effect. However, I don't think this is documented. Would
documenting this be enough to close this ticket? Or should F expressions
be assignable to the relation descriptors?
--
Ticket URL: <https://code.djangoproject.com/ticket/11541#comment:9>
* owner: nobody => Aman Pandey
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/11541#comment:10>