4

I am getting a import error in django. My main urls.py settings file is located at main/main/urls.py my module or app is located here main/apps/builder/urls.py.

traceback error

ImportError at /
No module named apps.builder.urls
Request Method: GET
Request URL:    ***************
Django Version: 1.4
Exception Type: ImportError
Exception Value:    
No module named apps.builder.urls
Exception Location: /usr/lib/python2.6/site-packages/django/utils/importlib.py in     import_module, line 35
Python Executable:  /usr/bin/python26
Python Version: 2.6.0
Python Path:    
['/home/pycode/main',
 '/usr/lib/python26.zip',
 '/usr/lib/python2.6',
 '/usr/lib/python2.6/plat-linux2',
 '/usr/lib/python2.6/lib-tk',
 '/usr/lib/python2.6/lib-old',
 '/usr/lib/python2.6/lib-dynload',
 '/usr/lib/python2.6/site-packages']
Server time:    Tue, 12 Jun 2012 12:39:17 -0500

main/main/urls.py

from django.conf.urls import patterns, include, url

urlpatterns = patterns('',
    url(r'^$', include('main.apps.builder.urls')),
)
1
  • Try with just 'apps.builder.urls' or 'main.main.apps.builder.urls' and see I guess it's got to do with the way you have laid out your applications. Also ensure that you have init.py in all folders Commented Jun 12, 2012 at 17:53

2 Answers 2

4

Your apps module must be below main/main or you have to make sure your apps folder is in your sys.path, probably best to set PYTHONPATH.

Sign up to request clarification or add additional context in comments.

2 Comments

could i just move my apps folder into main/main and change my urls.py to url(r'^$', include('apps.builder.urls')),
or everytime you run your server you can do sudo PYTHONPATH=<yourpath> python manage.py runserver
2

Did you add it to INSTALLED_APPS in your settings.py file?

https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps

also as ramdaz suggested each directory needs a __init__.py file even if it is empty.

1 Comment

yes i added it to installed apps in main/main/settings.py as apps.builder and yes all my directories have __init__.py

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.