Django Inner Join Queryset where there is no foreign key relation between two tables

2017-07-09 Thread Amisha Hans
down votefavorite <https://stackoverflow.com/questions/44998803/django-inner-join-queryset-where-there-is-no-foreign-key-relation-between-two-ta/44998962?noredirect=1#> Please Help ! I Want to know the inner join Queryset for the below mentioned raw oracle Query : -

Re: Django INNER JOIN

2010-07-28 Thread Roald de Vries
On Jul 28, 2010, at 6:02 PM, kostia wrote: Well, I used projects = projects.filter(favourites__user = request.user) And then I tired to order by 'date' field, which is in the Favourite model like here: projects = projects.filter(favourites__user = request.user)#.order_by(filter_field) And it

Re: Django INNER JOIN

2010-07-28 Thread kostia
Well, I used projects = projects.filter(favourites__user = request.user) And then I tired to order by 'date' field, which is in the Favourite model like here: projects = projects.filter(favourites__user = request.user)#.order_by(filter_field) And it throws me an error: "Cannot resolve keyword '

Re: Django INNER JOIN

2010-07-28 Thread Roald de Vries
On Jul 28, 2010, at 5:19 PM, kostia wrote: Thank you very much Roald, What is faster: projects = Project.objects.filter(favourites__user = request.user) or select_related('project') ? I think it doesn't matter much, but if one is faster, it should be the first one. If you only use the

Re: Django INNER JOIN

2010-07-28 Thread Daniel Roseman
On Jul 28, 4:16 pm, backdoc wrote: > > > > > >    fav_and_projs = ((f, f.project) for f in favourites) > > This may not be a Django question. But, I'm not familiar with this syntax. > Is this returning a tuple for ever item in favourites?  So, fav_and_projs > would be a tuple of tuples, like ((f1

Re: Django INNER JOIN

2010-07-28 Thread kostia
Thank you very much Roald, What is faster: projects = Project.objects.filter(favourites__user = request.user) or select_related('project') ? Kostia -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to dj

Re: Django INNER JOIN

2010-07-28 Thread backdoc
> >fav_and_projs = ((f, f.project) for f in favourites) > This may not be a Django question. But, I'm not familiar with this syntax. Is this returning a tuple for ever item in favourites? So, fav_and_projs would be a tuple of tuples, like ((f1, f.project1), (f2, fproject2), .(fn, fproje

Re: Django INNER JOIN

2010-07-28 Thread Roald de Vries
Dear Kostia On Jul 28, 2010, at 2:29 PM, kostia wrote: I have a model Favourite with fields User, Project, Date, what means that some user put some project as favourite on some date. I take all favourites filtered by this user and I want to INNER JOIN that info with Project model. How can I do t

Re: Django INNER JOIN

2010-07-28 Thread kostia
Still need your help -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options,

Re: Django INNER JOIN

2010-07-28 Thread kostia
import datetime from django.db import models from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User class Project(models.Model): author = models.ForeignKey(User, verbose_name=_('Author'), related_name='projects') title = models.CharFiel

Re: Django INNER JOIN

2010-07-28 Thread Sævar Öfjörð
It would help if you submitted your models - Sævar On Jul 28, 2:29 pm, kostia wrote: > I have a model Favourite with fields User, Project, Date, what means > that some user put some project as favourite on some date. I take all > favourites filtered by this user and I want to INNER JOIN that info

Django INNER JOIN

2010-07-28 Thread kostia
I have a model Favourite with fields User, Project, Date, what means that some user put some project as favourite on some date. I take all favourites filtered by this user and I want to INNER JOIN that info with Project model. How can I do that? Something like projects = Favourite.objects.filter(u