On Wed, Jun 4, 2014 at 8:51 AM, Vahe Evoyan <[email protected]> wrote:
> I have modules in the project with the same names, all placed in different
> applications.
>
> Particularly there are two apps that conflict and result an ImportError. The
> project structure approximately is as follows.
>
> project
>  |_ project
>    |_ settings.py
>    |_ ...
>  |_ apps
>    |_ A
>      |_ handlers
>        |_ B.py
>        |_ C.py
>    |_ B
>      |_ models.py
>
> The settings file adds apps directory to the system path.
>
> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
> sys.path.insert(0, os.path.join(BASE_DIR, "apps"))
>
> This configuration assumes that when I import the B.models it will use
> apps/B/models.py. Although the following line in the C.py file raise an
> import error as it imports the A/handlers/B.pywhich does not have models
> module.
>
> A/handlers/C.py:
>     from B.models import BModel
>
> The sys.path variable has a correct items, i.e. the first one in the list is
> /path/to/project/appsand sys.modules['B.models'] is referenced to the
> correct file.
>
> BTW, when I use Django's import_by_path function, everything works fine.
>
> Any ideas how I can solve the problem without renaming the modules?
>
> Posted sample sources on GitHub.
>
> Thanks in advance!
>

The simplest solution is to simply rename either app or component that
conflicts.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1KE-WunyPZuZZN79skNtA_MUsShNeHyGzwywNVx64fJxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to