These are chat archives for django/django

Feb 2017
Feb 28 2017 06:40

@koderNeptune the aggregate Sum should return a dict, an example in your case, when you print that total_amount should return {'getters_collected_amount__sum': 20}, you should change it to get int total;

total_amount = PairMembers.objects.filter(get_help_request_id=get_help_id).aggregate(

But, previously.... don't use default False in your request.POST.get if you wrapped it using int, because it should return an error Integer is not callable... you should change it to default int value. an example:

getters_balance = int(request.POST.get('getters_total_amount', 0))
Miracle Ayodele
Feb 28 2017 06:41
oh this is awesome @agusmakmun
Feb 28 2017 06:42
your welcome.. :smiley:
Miracle Ayodele
Feb 28 2017 06:42
but i wont want the record to save again once the maximum amount is reached
Feb 28 2017 06:57
has continued to conversation
Gururaj Jeerge
Feb 28 2017 08:21
Any one working with Django Rest Framework ?
Santiago Malter-Terrada
Feb 28 2017 10:13

Hello, I'm working on a quite complex query within multiple models, Case(), annotations and F() objects...

        # Match category
        queryset = queryset.annotate(
                When(category__in=user.interests.all(), then=Value(50)),

More extensive code sample:
I've tried so many things but I have duplicates when I combine annotate+Case() with a m2m... distinct() doesn't work. (or I'm using it wrongly)

What I'm trying to achieve is to compare attributes of a main Model (Topic) in order to calculate a "matching" score (compared to User attributes).

Does someone have any idea about the duplicates, or is thinking of an alternative to achieve the same result?

Thanks :)