Hey all, I am just starting with django; I think it is really cool, a big break from Java/Struts dev for me. Anyways, I am experimenting with a simple blog app. So, on to some issues. Here is output:
bastion:~ nick$ python dev/django-projects/myblog/manage.py sql blog BEGIN; CREATE TABLE "blog_authors" ( "id" serial NOT NULL PRIMARY KEY, "first_name" text NOT NULL, "last_name" text NOT NULL, "email" text NOT NULL ); CREATE TABLE "blog_articles" ( "id" serial NOT NULL PRIMARY KEY, "title" text NOT NULL, "content" text NOT NULL, "publish_date" timestamp with time zone NOT NULL, "author_id" integer NOT NULL REFERENCES "blog_authors" ("id") ); CREATE TABLE "blog_comments" ( "id" serial NOT NULL PRIMARY KEY, "title" text NOT NULL, "content" text NOT NULL, "publish_date" timestamp with time zone NOT NULL, "author_id" integer NOT NULL REFERENCES "blog_authors" ("id"), "related_article_id" integer NOT NULL REFERENCES "blog_articles" ("id") ); COMMIT; # so far so good # then... bastion:~ nick$ python dev/django-projects/myblog/manage.py shell Python 2.4.3 (#1, May 20 2006, 16:12:06) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from blog.models.blog import * >>> a = Article(title='Hi', content='Double Hi', publish_date='now') >>> a.save() Traceback (most recent call last): File "<console>", line 1, in ? File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/utils/functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/meta/__init__.py", line 1026, in method_save ','.join(placeholders)), db_values) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/db/base.py", line 10, in execute result = self.cursor.execute(sql, params) IntegrityError: ERROR: null value in column "author_id" violates not-null constraint INSERT INTO "blog_articles" ("title","content","publish_date","author_id") VALUES ('Hi','Double Hi','now',NULL) # ok. so I made a mistake. but what follows really puzzles me. >>> me = Author(first_name='Nick', last_name='Hristov', email='[EMAIL >>> PROTECTED]') >>> me.save() Traceback (most recent call last): File "<console>", line 1, in ? File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/utils/functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/meta/__init__.py", line 990, in method_save cursor = db.db.cursor() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/db/backends/postgresql.py", line 35, in cursor cursor.execute("SET TIME ZONE %s", [TIME_ZONE]) ProgrammingError: ERROR: current transaction is aborted, commands ignored until end of transaction block SET TIME ZONE 'GMT' # Wtf? I guess a transaction was opened in the previous save and it was not closed, so all of my following db queries are going to fail too? To some degree that sounds fine, I guess... it is fail safe. But how do I now abort the current transaction and start a fresh? # Or do my saves get batched and executed as a transaction? Given the previous save did not work, it should not be batched... Thanks for the help. Nick --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---