I am running a sample site on Django 1.5.1 but I am getting ImportError while creating Django app named "website". Here is my Application Heirarchy.
TrackLeech
-- __init__.py
-- manage.py
TrackLeech
-- __init__.py
-- setting.py
-- urls.py
-- wsgi.py
website
-- __init__.py
-- models.py
-- tests.py
-- views.py
templates
-- index.html
Now when I run the command, the server starts well at port 8000 but the localhost:8000 page shows ImportError
$ python manage.py runserver
Validating models...
0 errors found
July 24, 2013 - 13:29:03
Django version 1.5.1, using settings 'TrackLeech.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Internal Server Error: /
Traceback (most recent call last):
File "/home/chitrank/Documents/Google_App_Engine/venv/local/lib/python2.7/site- packages/Django-1.5.1-py2.7.egg/django/core/handlers/base.py", line 103, in get_response
resolver_match = resolver.resolve(request.path_info)
File "/home/chitrank/Documents/Google_App_Engine/venv/local/lib/python2.7/site- packages/Django-1.5.1-py2.7.egg/django/core/urlresolvers.py", line 321, in resolve
sub_match = pattern.resolve(new_path)
File "/home/chitrank/Documents/Google_App_Engine/venv/local/lib/python2.7/site- packages/Django-1.5.1-py2.7.egg/django/core/urlresolvers.py", line 223, in resolve
return ResolverMatch(self.callback, args, kwargs, self.name)
File "/home/chitrank/Documents/Google_App_Engine/venv/local/lib/python2.7/site- packages/Django-1.5.1-py2.7.egg/django/core/urlresolvers.py", line 230, in callback
self._callback = get_callable(self._callback_str)
File "/home/chitrank/Documents/Google_App_Engine/venv/local/lib/python2.7/site- packages/Django-1.5.1-py2.7.egg/django/utils/functional.py", line 29, in wrapper
result = func(*args)
File "/home/chitrank/Documents/Google_App_Engine/venv/local/lib/python2.7/site- packages/Django-1.5.1-py2.7.egg/django/core/urlresolvers.py", line 101, in get_callable
not module_has_submodule(import_module(parentmod), submod)):
File "/home/chitrank/Documents/Google_App_Engine/venv/local/lib/python2.7/site- packages/Django-1.5.1-py2.7.egg/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named website
I am unable to figure that this is the error in the new Django version 1.5.1 or I am making modules the different way or Should I reinstall the Django or should I use some other Django version. Please suggest me Do I need to change the Django I am using ?
you have to make sure you create the app at the basic way: python manage.py startapp website and set the name of the apps in the settings INSTALLED_APPS.
Hey I was also facing same issue with "login" name.
my app name was "login" and have feature.py in the same.
when i try to import feature using
from login import feature
IDE was not showing any issues. intellisense was working fine.
but when i tried to runserver it thrown ImportError: No module named feature. and as soon as i changed login to extended_login it worked.
So i think some Keywords are not acceptable as app names. You try changing your app name.
来源:https://stackoverflow.com/questions/17843361/python-django-importerror-no-module-named-website