On Wednesday, June 4, 2014 3:51:28 AM UTC-4, Vahe Evoyan 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.pyThe settings file adds
appsdirectory 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.modelsit will useapps/B/models.py. Although the following line in theC.pyfile raise an import error as it imports theA/handlers/B.pywhich does not havemodelsmodule.A/handlers/C.py: from B.models import BModelThe
sys.pathvariable has a correct items, i.e. the first one in the list is/path/to/project/appsandsyis referenced to the correct file.s.modules['B.models'] BTW, when I use Django's
import_by_pathfunction, everything works fine. Any ideas how I can solve the problem without renaming the modules?
Posted sample sources on GitHub.
Thanks in advance!
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/0e09ff68-d4a7-4353-afd3-0932205a7823%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment