Working in Django 1.0.2 with PostgreSQL backend the following produces an error: Operational Error at /report/agent_summary/ near "ON": syntax error
The SQL works if run in pgadminIII but with %s replaced by "2009-01-01". Must be a newbie error somewhere. def agent_summary(request): '''build a report showing the most recent advertisement (listing) for properties listed within the last 12 weeks''' startdate = date.today()-timedelta(7*12) cursor = connection.cursor() cursor.execute("SELECT DISTINCT ON (property_id) property_id, date, wha_property.propnum, wha_street.street_name, wha_suburb.suburb_name, wha_agent.first_name, wha_agent.last_name, wha_agency.name FROM wha_listing, wha_agent, wha_agency, wha_property, wha_street, wha_suburb WHERE wha_suburb.id = wha_street.suburb_id AND wha_street.id = wha_property.street_id AND wha_property.id = property_id AND wha_agency.id = wha_agent.agency_id AND wha_agent.id = agent_id AND date > %s ORDER BY property_id, date DESC", [startdate]) listings = cursor.fetchall() return render_to_response('wha/agent_summary.html', {'listings': listings}) Any help very much appreciated. Steep learning curve. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---