Monday, March 30, 2020

Re: Django ORM query with joins

Sorry its like this...
posts.objects.values('id', 'details', 'user__name' )

On Mon, 30 Mar 2020, 7:46 pm Suraj Thapa FC, <surajthapafc@gmail.com> wrote:
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/CAPjsHcHEMn1QWQiFUKD5rgY3yu9_muxWGj9STop8cz83pUkTcg%40mail.gmail.com.

No comments:

Post a Comment