Error in the ORM Tutorial.

Issue #1817 resolved
Former user created an issue

I was following along with the ORM tutorial when I ran into a problem in this part: http://www.sqlalchemy.org/docs/ormtutorial.html#building-a-many-to-many-relationship

Here's what happened:

post = BlogPost("Wendy's Blog Post", "This is a test", wendy) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 1, in init File "/usr/local/Cellar/python/2.6.4/lib/python2.6/site-packages/sqlalchemy/orm/attributes.py", line 151, in set self.impl.set(instance_state(instance), instance_dict(instance), value, None) AttributeError: 'BlogPost' object has no attribute '_sa_instance_state'

This seems to happen any time I try to instantiate a BlogPost. What is going wrong?

Comments (1)

  1. Mike Bayer repo owner

    the BlogPost object was instantiated before a mapper was created. or clear_mappers() was called, then a BlogPost was instantiated.

    The ORM tutorial itself runs successfully.

  2. Log in to comment