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"
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
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?
*
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
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
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
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?
>
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,
>
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 &
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
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
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
>
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
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...
>
>
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 =
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
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
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 =
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
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']}
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,
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={
>
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'
}
)
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
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={
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={
26 matches
Mail list logo