Monday, March 30, 2020

Re: Django ORM query with joins

posts.model.values('id', 'details', 'user__name' )

On Mon, 30 Mar 2020, 5:26 pm Anoop Thiparala, <anthiparala@gmail.com> wrote:
I need help with a django query...I have two models

1) POSTS
==>id
==>details
==>user(foreign key to user table)

2) USER
==>id
==>email
==>name

SQL VERSION: SELECT POSTS.ID, POSTS.DETAILS, USER.NAME FROM POSTS, USER WHERE POSTS.USER == USER.ID;

I require these details in the same queryset...is it possible ? 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c59d7b0c-834f-47fe-8162-5e34f42c51f9%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPjsHcHsWSUuEgKdy%2BXQL0NLn4dzTco-t_SQuOcVzBAZm4_XCw%40mail.gmail.com.

No comments:

Post a Comment