Hi Rogério,

You can output to json using templates if this is the only thing holding you back from a working solution using regroup. You can use render_to_string with a json template which you can then return with an HttpResponse. It doesn't take advantage of the serialization library but it does work.

-- Casey

On 10/28/2010 09:41 AM, Rogério Carrasqueira wrote:
Hi Franklin!

Thanks for you answer. Unfortunatelly I need to output my results on a
JSON file. Do you have any other approach?

Cheers,

Rogério Carrasqueira

---
e-mail: [email protected]
<mailto:[email protected]>
skype: rgcarrasqueira
MSN: [email protected] <mailto:[email protected]>
ICQ: 50525616
Tel.: (11) 7805-0074



2010/10/28 Franklin Einspruch <[email protected]
<mailto:[email protected]>>

    It may not be a complete answer, but you should know about {% regroup
    %} just in case:

    
http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#regroup

    - Franklin

    --
    Art, writing, journal: http://einspruch.com
    Comics: http://themoonfellonme.com




    2010/10/28 Rogério Carrasqueira <[email protected]
    <mailto:[email protected]>>:
     > Hello!
     >
     > I'm having an issue to make complex queries in django. My problem
    is, I have
     > a model where I have the sales and I need to make a report
    showing the sales
     > amount per month, by the way I made this query:
     >
     > init_date = datetime.date(datetime.now()-timedelta(days=365))
     > ends_date = datetime.date(datetime.now())
     > sales =
     >
    
Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_created__month).aggregate(total_sales=Sum('total_value'))
     >
     > At the first line I get the today's date past one year
     > after this I got the today date
     >
     > at sales I'm trying to between a range get the sales amount
    grouped by
     > month, but unfortunatelly I was unhappy on this, because this error
     > appeared:
     >
     > global name 'date_created__month' is not defined
     >
     > At date_created is the field where I store the information about
    when the
     > sale was done., the __moth was a tentative to group by this by month.
     >
     > So, my question: how to do that thing without using a raw sql
    query and not
     > touching on database independence?
     >
     > Thanks so much!
     >
     > Rogério Carrasqueira
     >
     > ---
     > e-mail: [email protected]
    <mailto:[email protected]>
     > skype: rgcarrasqueira
     > MSN: [email protected] <mailto:[email protected]>
     > ICQ: 50525616
     > Tel.: (11) 7805-0074
     >
     > --
     > You received this message because you are subscribed to the
    Google Groups
     > "Django users" group.
     > To post to this group, send email to
    [email protected] <mailto:[email protected]>.
     > To unsubscribe from this group, send email to
     > [email protected]
    <mailto:django-users%[email protected]>.
     > For more options, visit this group at
     > http://groups.google.com/group/django-users?hl=en.
     >

    --
    You received this message because you are subscribed to the Google
    Groups "Django users" group.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:django-users%[email protected]>.
    For more options, visit this group at
    http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to