On Jan 6, 2012, at 10:15 PM, Paul Kraus wrote:
> I have an address class that i would like to use in several locations for
> instance vendors need addresses and customers need addresses.
>
> I have my model split between 2 files globals and ar. A customer can have a
> default bill to address, default ship to address, and multiple address to
> choose from for ship to's beyond the default. I have the bill_to and ship_to
> default working fine but for the life of me can't figure out how to create
> the locations reference. I know how to do it if i put it on the address class
> but then i have python import issues obviously.
to work around import issues, specify the name of the class to relationship()
as a string:
relationship("Address")
This draws upon the class by name from a registry that's represented within the
declarative base, and is only resolved when the mappings are first used,
assumed to be after all modules have been imported.
docs:
http://www.sqlalchemy.org/docs/orm/relationships.html#one-to-many
http://www.sqlalchemy.org/docs/orm/extensions/declarative.html#configuring-relationships
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.