Python imports from crossreferencing packages -
Currently I'm trying to write my first Python library and I have encountered the following problem:
I have the following import in my package myapp.factories:
from myapp.models import * and my package in myapp.models The following is the model: There is a need for a model in the package of my factories, but within one model I also need one of the factories. I / I> Myapp.factories Import
< / Pre >If I now call a factory requiring a factory, I get the following error:
Error: Name: Global Name 'MyMoldFactor' is not defined < / Pre> I'm pretty sure that there is something to do with the order in which the scripts are loaded but I can not seem to know how these cross-references work.
"I also need a factory inside a model" - just import that factory where You need it:
class SomeModel: def some_method itself): import from myapp.factories SomeFactory SomeFactory (). Do_something ()
Comments
Post a Comment