没有模块名称书

时间:2015-10-30 11:14:48

标签: python django traceback

我的python服务器中使用django时出现以下错误。

function setSrc(){
$('.bgimg').prop('src','https://maps.googleapis.com/maps/api/streetview?size=600x300&location=' + $('#street').val() + ',' + $('#city').val() + '&key=API_KEY');
}

<form id="form-container" class="form-container" onSubmit="setSrc();">

我的项目结构如下:

C:\Users\Nuno\Favorites\Desktop\Django\mysiteproject>python manage.py runserver
Unhandled exception in thread started by <function wrapper at 0x03180B70>
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 229, in
wrapper
    fn(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.
py", line 107, in inner_run
    autoreload.raise_last_exception()
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 252, in
raise_last_exception
    six.reraise(*_exception)
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 229, in
wrapper
    fn(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Python27\lib\site-packages\django\apps\registry.py", line 115, in pop
ulate
    app_config.ready()
  File "C:\Python27\lib\site-packages\django\contrib\admin\apps.py", line 22, in
 ready
    self.module.autodiscover()
  File "C:\Python27\lib\site-packages\django\contrib\admin\__init__.py", line 24
, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "C:\Python27\lib\site-packages\django\utils\module_loading.py", line 74,
in autodiscover_modules
    import_module('%s.%s' % (app_config.name, module_to_search))
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\Users\Nuno\Favorites\Desktop\Django\mysiteproject\books\admin.py", li
ne 4, in <module>
    from mysiteproject.books.models import Publisher, Author, Book
ImportError: No module named books.models

有人知道我做错了什么吗? python版本:1.7.9 Django版本:1.8.4

1 个答案:

答案 0 :(得分:2)

更改您的导入代码:

from mysiteproject.books.models import Publisher, Author, Book

from books.models import Publisher, Author, Book