| The FinancialContent Network SocialPicks Community | MarketMinute Monitor | MarketMinute Market Updates | MarketMinute Stock News |
|
Sr. Analyst
|
Via Evan Reiser's Blog:
Django doesnt officially yet support group by, however the code to acomplish this is actually hidden inside.  If you had a model that tracked registrations, which contained a FK to the user that refered the new user such as: class Registration(models.Model):      ...      referer = models.ForeignKey(User,null=True,blank=True) >>> from registration.models import Registration >>> query_set = Registration.objects.extra(select={'count': 'count(1)'}, order_by=['-count'],where=['referer_id is not null']).values('count', 'referer')  >>> query_set.query.group_by = ['referer_id'] >>> for row in query_set: ...  print row                                                                  ... {'count': 26L, 'referer': 6384} {'count': 4L, 'referer': 6871} {'count': 3L, 'referer': 9993} {'count': 2L, 'referer': 7804} {'count': 2L, 'referer': 7892} {'count': 2L, 'referer': 9699} {'count': 1L, 'referer': 6111} {'count': 1L, 'referer': 7821} {'count': 1L, 'referer': 5025} this is as of Last Changed Rev: 9037 Last Changed Date: 2008-09-15 14:06:02 -0400 (Mon, 15 Sep 2008)
Read the rest of original post »
|
|
|
IN THE PRESS |
|
|
|
|
|
|
| About | RSS | Feedback | Contact Us | Terms of Service | Privacy |
© 2009 FinancialContent Services, Inc. |
|
Data powered by FinancialContent. All Rights Reserved. Quotes delayed at least 20 minutes unless otherwise indicated. |
|
None of the information contained on SocialPicks.com constitutes a recommendation by SocialPicks or its users that any particular security, portfolio of securities, transaction, or investment strategy is suitable for any specific person. SocialPicks is not responsible for the posts, discussions, and recommendations of the users on the Site. SocialPicks does not provide investment advice. You must make your own independent decisions regarding any security, portfolio of securities, transaction, or investment strategy mentioned on the website. SocialPicks' users' past results are not necessarily indicative of future performance. Neither SocialPicks nor any of its users guarantees any specific outcome or profit, and you should be aware of the real risk of loss in following any strategy or investments discussed on the website. You understand and agree that you use the Site and Services at your own discretion and risk and that you will be solely responsible for any damages that arise from such use. Before acting on any information contained on the website, you should consider whether it is suitable for your particular circumstances and strongly consider seeking advice from your own financial or investment adviser. |