Just as an aside, I would not call a single class a "model". The model
is the whole collection of your database objects and their relations.
> OK, maybe this is a short way of saying it:
> How do I reference methods from other models inside of a model without
> creating this import dependency issue?
I recommend defining related model classes inside the same module.
Also note that SQLAlchemy allows you to pass as-yet undefined objects as
strings.
Or, you can add attribute later, after you declared both classes (e.g.
in __init__.py, after you imported all model classes).
-- Christoph
In case of doubt, I recommend asking on the SA mailing list. There you
will get qualified answers to any SA question very quickly.
-- Christoph
That's not working.
class Foo(object):
some_attribute = Bar() # bails out
class Bar(object):
other_attribute = Foo()
Define them after both classes are known (which arguably is easier in
one module of course), or use Strings - at least Elixir allows that.
class Foo(Entity):
bars = OneToMany("Bar")
class Bar(Entity):
foo = ManyToOne("Foo")
Diez