I've posted the following comment at
http://www.djangoproject.com/documentation/tutorial1/ but thought
perhaps it belongs here.

n many instances, if you make a mistake following the tutorial, either
accidentally or intentionally (e.g., if --to experiment-- you leave out
the 'votes' parameter when creating a choice), you may get an SQL
transaction abort and subsequent statements will fail. There's
apparently no recovery mechanism other than exiting Python and
restarting. This is applicable to PostgreSQL and Python 2.4, but perhaps
happens with other databases.

Example:

>>> Choice.objects.filter(poll__pub_date=2005)
Traceback (most recent call last):
File "<console>", line 1, in ?
File "/usr/local/lib/python2.4/site-packages/django/db/models/query.py",
line 97, in __repr__
return repr(self._get_data())
File "/usr/local/lib/python2.4/site-packages/django/db/models/query.py",
line 430, in _get_data
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.4/site-packages/django/db/models/query.py",
line 172, in iterator
cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") +
",".join(select) + sql, params)
File
"/usr/local/lib/python2.4/site-packages/django/db/backends/util.py",
line 12, in execute
return self.cursor.execute(sql, params)
ProgrammingError: ERROR: invalid input syntax for type timestamp with
time zone: "2005"

SELECT
"polls_choice"."id","polls_choice"."poll_id","polls_choice"."choice","polls_choice"."votes"
 FROM "polls_choice" INNER JOIN "polls_poll" AS "polls_choice__poll" ON 
"polls_choice"."poll_id" = "polls_choice__poll"."id" WHERE 
("polls_choice__poll"."pub_date" = '2005')
>>> Choice.objects.filter(poll__pub_date__year=2005)
Traceback (most recent call last):
File "<console>", line 1, in ?
File "/usr/local/lib/python2.4/site-packages/django/db/models/query.py",
line 97, in __repr__
return repr(self._get_data())
File "/usr/local/lib/python2.4/site-packages/django/db/models/query.py",
line 430, in _get_data
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.4/site-packages/django/db/models/query.py",
line 170, in iterator
cursor = connection.cursor()
File
"/usr/local/lib/python2.4/site-packages/django/db/backends/postgresql/base.py", 
line 46, in cursor
cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
ProgrammingError: ERROR: current transaction is aborted, commands
ignored until end of transaction block

SET TIME ZONE 'America/Chicago'
>>>



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