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

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -