Help regarding query.

2019-01-15 Thread Mohit Solanki
Can someone explain why group by after annotations yield wrong result. More details at https://stackoverflow.com/questions/54205761/django-group-by-yield-wrong-result-after-filtering-by-annotated-field -- You received this message because you are subscribed to the Google Groups "Django users"

Re: help with query set

2013-07-14 Thread Mike Dewhirst
On 15/07/2013 1:11am, Bobby Roberts wrote: hi. I need help with this simple setup. i need to get a list of announcements where active =1 and the discontinueDate is either null OR less than NOW. I haven't looked at your code but your words above indicate you want all announcements which

help with query set

2013-07-14 Thread Bobby Roberts
hi. I need help with this simple setup. i need to get a list of announcements where active =1 and the discontinueDate is either null OR less than NOW. There are two issues: 1) the filter doesn't work 2) numannouncements always equals 1 even when nothing is returned any ideas? *

Re: Need help with Query: Q Objects and .extra()

2012-11-18 Thread est
his helps anyone with the same problem. On Saturday, 14 November 2009 03:58:34 UTC+8, Info Cascade wrote: > > Hi -- > > I need help with a query! > > Currently using .extra to do full text query on the article.title field. > > art_list = Article.objects.filter

Re: Need help with Query: Q Objects and .extra()

2009-11-13 Thread Tomasz Zieliński
On 13 Lis, 20:58, Info Cascade wrote: >  art_list = Article.objects.filter(status__status='PUBLISHED', >                 QExtra(where=['title_tsv @@ plainto_tsquery(%s)'], >                     params=[term])) | > Q(tags__name__icontains=term)).distinct() I'm not

Need help with Query: Q Objects and .extra()

2009-11-13 Thread Info Cascade
Hi -- I need help with a query! Currently using .extra to do full text query on the article.title field. art_list = Article.objects.filter(status__status='PUBLISHED') art_list = art_list.extra( where=['title_tsv @@ plainto_tsquery(%s)'], params=[term]) That works great. I want to add

Re: Help on query

2009-09-30 Thread Jay
Use the aggregation way: user.report_set.annotate(count = Count('report_set')).filter(count = 1) On Sep 29, 10:39 pm, luismmontielg wrote: > yeah, something like that is what I want, but to me, that is not the > best way of doing it ... > Maybe there's a simpler way? >

Re: Help on query

2009-09-29 Thread luismmontielg
yeah, something like that is what I want, but to me, that is not the best way of doing it ... Maybe there's a simpler way? thanks in advance On Sep 29, 8:46 am, sunn wrote: > This should hopefully work as well > user_reports = user.report_set.exclude(users__id__lt = user.id, >

Re: Help on query

2009-09-29 Thread sunn
This should hopefully work as well user_reports = user.report_set.exclude(users__id__lt = user.id, users_id_gt = user.id) On Sep 29, 4:32 pm, sunn wrote: > If you don't want to write SQL I think the easiest way is to combine > two querysets > > # You can combine queries with &

Re: Help on query

2009-09-29 Thread sunn
If you don't want to write SQL I think the easiest way is to combine two querysets # You can combine queries with & and |. >>> s1 = Article.objects.filter(id__exact=1) >>> s2 = Article.objects.filter(id__exact=2) >>> s1 | s2 [, ] >>> s1 & s2 [] From

Re: Help on query

2009-09-29 Thread luismmontielg
that brings me all reports that have that user, but also the reports that have user and user2.. i want only the reports that have 1 user and id is equal to user.id On Sep 29, 4:35 am, Joshua Russo wrote: > oh ok, so just use the filter(user_id = user.id) > > On Tue, Sep

Re: Help on query

2009-09-29 Thread Joshua Russo
oh ok, so just use the filter(user_id = user.id) On Tue, Sep 29, 2009 at 12:21 AM, luismmontielg wrote: > > Actually there it is, > > users = models.ManyToManyField(User, symmetrical=True) > > but I want to filter only the reports that contain only this user, or >

Re: Help on query

2009-09-28 Thread luismmontielg
Actually there it is, users = models.ManyToManyField(User, symmetrical=True) but I want to filter only the reports that contain only this user, or exclude the ones that do not have the user. Thanks again On 28 sep, 20:16, luismmontielg wrote: > sorry forgot to

Re: Help on query

2009-09-28 Thread luismmontielg
sorry forgot to mention its a many to many relation so a report can have multiple users On Sep 28, 4:29 pm, Joshua Russo wrote: > On Mon, Sep 28, 2009 at 7:55 PM, luismmontielg wrote: > > > > > > > > > Hello, > > I have my models like this... > >

Re: Help on query

2009-09-28 Thread Joshua Russo
On Mon, Sep 28, 2009 at 7:55 PM, luismmontielg wrote: > > Hello, > I have my models like this... > > class Report(models.Model): >title = models.CharField(max_length=50, blank=True) >users = models.ManyToManyField(User, symmetrical=True) >categories =

Help on query

2009-09-28 Thread luismmontielg
Hello, I have my models like this... class Report(models.Model): title = models.CharField(max_length=50, blank=True) users = models.ManyToManyField(User, symmetrical=True) categories = models.ManyToManyField("Category", through='ReportDetail', \ symmetrical=True) I

Re: Help on query

2009-05-19 Thread Daniel Roseman
On May 19, 12:11 pm, Lokesh wrote: > class Users(models.Model): >     userId = models.IntegerField(max_length=2, primary_key=True) >     userName = models.CharField(max_length=10, null=False, > blank=False) > >     def __unicode__(self): >         return self.userName

Help on query

2009-05-19 Thread Lokesh
class Users(models.Model): userId = models.IntegerField(max_length=2, primary_key=True) userName = models.CharField(max_length=10, null=False, blank=False) def __unicode__(self): return self.userName class MotherTongue(models.Model): MT_id =

Re: need help in query set

2009-05-14 Thread Michael
On Thu, May 14, 2009 at 12:01 PM, Prabhjyot Singh wrote: > > I am using >resultset = queryset.get(status__in=['pending']) > but it is giving me error which says: > > Exception Type: MultipleObjectsReturned > Exception Value: > > get() returned more

need help in query set

2009-05-14 Thread Prabhjyot Singh
I am using resultset = queryset.get(status__in=['pending']) but it is giving me error which says: Exception Type: MultipleObjectsReturned Exception Value: get() returned more than one WapAd -- it returned 3! Lookup parameters were {'status__in': ['pending']}

Re: Need help for query, how could i do this with django ? or a raw SQL.

2006-03-25 Thread Andy Dustman
On 3/25/06, coulix <[EMAIL PROTECTED]> wrote: > > i got it working : > > def _module_get_top_users(limit): > cursor = db.cursor() > cursor.execute(""" > SELECT auth_users.username, COUNT(*) AS count > FROM auth_users,

Re: Need help for query, how could i do this with django ? or a raw SQL.

2006-03-24 Thread Andy Dustman
On 3/24/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > coulix wrote: > > Hello, > > I was trying to play with custom query but i didnt manage to get it > > working, > > I too could not get the custom query from the API reference working: > > polls.get_list( > select={ >

Re: Need help for query, how could i do this with django ? or a raw SQL.

2006-03-24 Thread [EMAIL PROTECTED]
coulix wrote: > Hello, > I was trying to play with custom query but i didnt manage to get it > working, I too could not get the custom query from the API reference working: polls.get_list( select={ 'choice_count': 'SELECT COUNT(*) FROM choices WHERE poll_id = polls.id' } )

Re: Need help for query, how could i do this with django ? or a raw SQL.

2006-03-24 Thread Rock
Dropping down to the raw SQL level is easy... Assuming my_sql_command is a string with your select statement... from django.core.db import db cursor = db.cursor() cursor.execute( my_sql_command ) row = cursor.fetchone() result = row[0] You might prefer fetchall(), but I leave the data

Need help for query, how could i do this with django ? or a raw SQL.

2006-03-24 Thread coulix
Hello, I was trying to play with custom query but i didnt manage to get it working, for example this one whcih i found on the mail list : Polls.get_list( select={ 'choice_count': { db_table='choices', db_columns=['COUNT(*)'] kwargs={

Need help for query, how could i do this with django ? or a raw SQL.

2006-03-24 Thread coulix
Hello, I was trying to play with custom query but i didnt manage to get it working, for example this one whcih i found on the mail list : Polls.get_list( select={ 'choice_count': { db_table='choices', db_columns=['COUNT(*)'] kwargs={