Hi there!
Finally got some part of the site working under M-R. It's a major edit
due to our large code base, complex models and many custom template
tags... :( I will try to post some of the things I learned along the
way when I get this done...

Here is the problem I'm having with right now:
Old way:
select = {
        'votes': 'SELECT COUNT(*) FROM faxian_votes WHERE
story_id=faxian_storys.id',
}
order_by = ('-votes',)
period = timedelta(days=self.period)
sl = storys.get_list(promotion_ts__isnull=False,
promotion_ts__gte=datetime.now()-period, select=select,
order_by=order_by, limit=10)

New way (with the error of "no such column: faxian_story.votes"):

select = {
        'votes': 'SELECT COUNT(*) FROM faxian_votes WHERE
story_id=faxian_storys.id',
}
order_by = '-votes'
period = timedelta(days=self.period)
sl = Story.objects.extra(select).filter(promotion_ts__isnull=False,
promotion_ts__gte=datetime.now()-period).order_by(order_by)[:10]

>From the debug info you can see the sql with the m-r version is:
'SELECT
"faxian_story"."id","faxian_story"."url","faxian_story"."title","faxian_story"."category_id","faxian_story"."summary","faxian_story"."submission_ts","faxian_story"."submission_user_id","faxian_story"."promotion_ts","faxian_story"."snapshot_ts","faxian_story"."update_ts",(SELECT
COUNT(*) FROM faxian_votes WHERE story_id=faxian_storys.id) AS "votes"
FROM "faxian_story" WHERE ("faxian_story"."promotion_ts" IS NOT NULL
AND "faxian_story"."promotion_ts" >= ?) ORDER BY "faxian_story"."votes"
DESC LIMIT 10 '

Clearly ORDER BY "faxian_story"."votes" is wrong.

Any hint? 

Best Regards,
--FX


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to