Nope, that just gets me "AttributeError: 'module' objects has no
attribute 'models'". :/

It doesn't work to just to 'import modelA' and then reference
modelA.Class1 or modelA.models.Class1 either; that just gives me the
same error.

On Jan 10, 2:38 pm, Muchanic <[EMAIL PROTECTED]> wrote:
> import xxx means 'import module xxx' - since Class1 is a class, and
> not a module, that won't work.
>
> If you change the import statements in both modules to something of
> the form 'import modelA.models as models_A' then referencing the
> classes as 'models_A.Class1', does that work?
>
> On Jan 11, 8:27 am, Josh Ourisman <[EMAIL PROTECTED]> wrote:
>
> > Hmm. That implies that I should be using 'import modelA.models.Class1'
> > rather than 'from modelA.models import Class1'. However, that syntax
> > doesn't seem to actually work. If I remove the circular imports for a
> > moment, 'from modelA.models import Class1' works just fine, but if I
> > use 'import modelA.models.Class1' I get a 'ImportError: No module
> > named Class1'.
>
> > I'm clearly missing _something_ here, and the advice given there
> > doesn't seem to work. Can anyone help me out?
>
> > On Jan 10, 1:40 pm, Muchanic <[EMAIL PROTECTED]> wrote:
>
> > > Check this 
> > > out:http://www.python.org/doc/faq/programming/#what-are-the-best-practice...
>
> > > On Jan 11, 6:54 am, Josh Ourisman <[EMAIL PROTECTED]> wrote:
>
> > > > I have two models, modelA and modelB. ModelA needs classB1 and classB2
> > > > from modelB, while modelB needs classA1 from classA.
>
> > > > So, in the models.py file for modelA I have 'from modelB.models import
> > > > classB1, classB2'. This worked just fine until I added to the
> > > > models.py file for modelB 'from modelA.models import classA1' after
> > > > also adding the class B3 that needed to reference classA1. Now when I
> > > > try to syncdb it tells me that modelA cannot import class B1.
>
> > > > Is there some particular reason that such cross-importing wouldn't be
> > > > possible? Do I need to use a different importing syntax or something?- 
> > > > Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to