Just going to transfer the view into a real table. Will let you know if that doesn't solve the problem!
On Jan 19, 12:57 pm, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Mon, 2009-01-19 at 04:38 -0800, phoebebright wrote: > > Generic view - year_archive, is not working for me. There are no > > errors displayed and no data either. On investigation, there seems to > > be a mysql error that is causing the problem and it could be related > > to the my using a view instead of a table as the source for the mode. > > The original date field is not a date but is converted to a date in > > the view and maybe this is the problem. > > [...] > > > If I run the query manually in mysql and add quotes around the range > > values, > > > BETWEEN '2007-01-01 00:00:00' and '2007-12-31 23:59:59.99' > > > it works fine but not without the quotes. > > > This may be a red herring - the toolbar might be stripping quotes from > > the query. > > Yes, that is a red herring. It's not the debug toolbar, but a limitation > of the Python DB wrappers. There's no public API to ask them how they > are about to quote parameters. So the strings you get from > django.db.connection.queries (which is what the debug toolbar is showing > you) are the query strings with the parameter values substituted in for > the "%s" placeholders. It's actually the raw_sql string that is passed > to the DB wrapper (MySQLdb in your case), along with a couple of Python > objects for the parameters. It takes care of quoting things correctly > and feeding the resulting string to the database correctly. > > Everything you've written looks right. So I'd be suspicious of your > database view, as you are. > > As you deduce, if we broke archive_year at any point, I suspect it would > take about 23 seconds before somebody reported the bug. Generic views > tend to get used a lot. :-) > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---