Thanks. So if I have this:
def my_custom_sql(self): from django.db import connection cursor = connection.cursor() cursor.execute("SELECT foo FROM bar WHERE baz = %s", [self.baz]) row = cursor.fetchone() return row Where would I put that if I intend to use the data mainly as a templatetag to place in various pages? On Aug 23, 1:57 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > The django ORM does not currently have native support for aggregates. > However there is a super promising GSOC project that was just > completed, and will likely go in shortly after 1.0(since we are in > feature freeze for now), so your options are to: a) use the patch the > GSOC student has here:http://code.djangoproject.com/ticket/3566, b) > Write the manual SQL for now and switch to that onces it's committed > to django proper > > On Aug 23, 1:44 pm, [EMAIL PROTECTED] wrote: > > > I have entries from the different users, they're entering the total > > number of steps they walked during a particular period of time, that > > they set. > > > So the model is setup like > > > user (fk) > > start_date = DateField() > > end_date = DateField() > > steps = IntergerField() > > > What I want to do is on the user's detail page to sum all the entries > > in the db for that model where user = page_user. I know with SQL you > > can do a query and just SUM(steps) as total_steps WHERE user = > > get_user. Is there a way, better/preferred, to do it with Django? > > > Also, on the site's front page, I'd like to list the top 10 total as > > well. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---