Somewhat effective way of using values() #732
rrauenza
started this conversation in
Show and tell
Replies: 2 comments
-
|
Thanks a lot! This is actually not obvious at all |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@neoden My 5 years older self now doesn't remember why I added this -- I didn't state what problem I was solving! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I wonder if you might want to document this alternative when using values()? Even though this isn't really django-polymorphic specific, I think you're the one adding in the ctype.
In this example, we have A->B->C and A->D->E
E has a column 'foo', and C has a column 'bar'.
This works by joining in the model name from the ctype. Then also joining in the specific attributes of the inherited models ...
A.objects.values('polymorphic_ctype__model', 'b__c__foo', 'd__e__bar')
One could look at the model string returned instead of isinstance and then select which fields to look at in the code. The irrelevant ones end up being None.
...maybe this is obvious, but it was kind of an Aha! moment for me when trying to convert some queries to values().
Beta Was this translation helpful? Give feedback.
All reactions