On 5/13/15 1:14 PM, willian coelho wrote:
Follow the complete Stack Trace:
|
Traceback (most recent call last):
File "/Users/macbookair2011/Desktop/projects/portautos/manage.py",
line 194, in <module>
manager.run()
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/flask_script/__init__.py",
line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/flask_script/__init__.py",
line 383, in handle
res = handle(*args, **config)
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/flask_script/commands.py",
line 216, in __call__
return self.run(*args, **kwargs)
File "/Users/macbookair2011/Desktop/projects/portautos/manage.py",
line 41, in load_types_and_makers
t = Type(name=type_)
File "<string>", line 2, in __init__
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/instrumentation.py",
line 324, in _new_state_if_none
state = self._state_constructor(instance, self)
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py",
line 725, in __get__
obj.__dict__[self.__name__] = result = self.fget(obj)
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/instrumentation.py",
line 158, in _state_constructor
self.dispatch.first_init(self, self.class_)
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/event/attr.py",
line 260, in __call__
fn(*args, **kw)
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py",
line 2702, in _event_on_first_init
configure_mappers()
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py",
line 2598, in configure_mappers
mapper._post_configure_properties()
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py",
line 1696, in _post_configure_properties
prop.init()
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.py",
line 144, in init
self.do_init()
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py",
line 1551, in do_init
self._setup_join_conditions()
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py",
line 1625, in _setup_join_conditions
can_be_synced_fn=self._columns_are_mapped
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py",
line 1893, in __init__
self._determine_joins()
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py",
line 1959, in _determine_joins
consider_as_foreign_keys=consider_as_foreign_keys
File "<string>", line 2, in join_condition
File
"/Users/macbookair2011/Documents/envs/portautosapp/lib/python2.7/site-packages/sqlalchemy/sql/selectable.py",
line 707, in _join_condition
b.foreign_keys,
AttributeError: 'tuple' object has no attribute 'foreign_keys'
|
there's a comma somewhere. The code you have sent is incomplete. There
is no mapping "Version" for example.
|
|
Em quarta-feira, 13 de maio de 2015 12:49:43 UTC-3, willian coelho
escreveu:
Hello everyone,
I`m getting an error when creating a new instance of my model
`Type`. I have a many-to-many relationship between Type and Maker.
Code:
|
type_maker =db.Table('type_maker', db.metadata,
db.Column('type_id',db.Integer,db.ForeignKey('type.id
<http://type.id>')),
db.Column('maker_id',db.Integer,db.ForeignKey('maker.id
<http://maker.id>')))
classType(db.Model):"""VehicleType """__tablename__ ='type'id
=db.Column(db.Integer,primary_key=True) name
=db.Column(db.String(50),unique=True,index=True) makers
=db.relationship('Maker',secondary='type_maker',backref=db.backref('type'))def__repr__(self):return'<Type
#{}: {}>'.format(self.id,self.name)
classMaker(db.Model):"""VehicleMaker """__tablename__
='maker'id =db.Column(db.Integer,primary_key=True) name
=db.Column(db.String(50),index=True) versions
=db.relationship('Version',backref=db.backref('maker'))def__repr__(self):return'<Maker
#{}: {}>'.format(self.id,self.name)
type_ =Type(name='Car')
|
Error:
|
'tuple'objecthas noattribute 'foreign_keys'
|
What is wrong with the code?
Thanks in advance!
Michael Coelho.
--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.