Django ORM: query of two models -
I have 2 models I use this model to show avatars in comments.
django_comments:
user_id comment .....
myapp_profile
User_id image_path ......
Actually I cursor Execute () with a raw query, to get this data
- --------------------- - 'user_id' 'image_path' 'comment' ------- ---------- - ------ 3 name.jpg test
But I want to do in "Dijenjo Yam Ways"
Any solution?
Thanks
Think about this: What will you get? This will not be an example of any model, right?
However, with the new annotated () and F () features, you can drag something like this:
comment.Object.All (). Annotated (image_path = F ('user__profile__image_path'))
Of course, you always:
comments.Obsets.All (). Get image_path from select_related ()
and x_user.get_profile (). Image_path
Comments
Post a Comment