简体   繁体   English

Django python - 找不到模块

[英]Django python - Module not found

I am a newbie so I might have done something stupid. 我是新手,所以我可能做了些蠢事。 running python 3.3 and Django 1.6.2. 运行python 3.3和Django 1.6.2。

When I run the local server via command line, this is the error I receive "P/1.1 404 1712" and error on the browser is "module not found" and the exception location direct me urls.py line 22; 当我通过命令行运行本地服务器时,这是我收到的错误“P / 1.1 404 1712”,浏览器上的错误是“找不到模块”,异常位置指示我urls.py第22行;

document_root=settings.STATIC_ROOT)

this is a part of urls.py: 这是urls.py的一部分:

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

from django.conf import settings
from django.conf.urls import static



from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    url(r'^$', 'signups.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^admin/', include(admin.site.urls)),

)


if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL,
                          document_root=settings.STATIC_ROOT)

    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)

This is how my settings.py looks: 这是我的settings.py看起来的样子:

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/whattheheck/static/'

# Template location
TEMPLATE_DIRS = {
    os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "templates"),

}

if DEBUG:
    MEDIA_URL = '/whattheheck/media/'
    STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "static-only")
    MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "media")
    STATICFLIES_DIRS = (
        os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "static")

    )

Can someone help please? 有人可以帮忙吗?

You forgot one static in the import statement, see the documentation : 您在import语句中忘记了一个static请参阅文档

from django.conf.urls.static import static
                    # ^^^^^^ this one

Right now, it tries to use the static module as a function but obviously, it does not work. 现在,它试图将static模块用作函数,但很明显,它不起作用。 The error 'module' object is not callable is raised when you are trying to use a module object (for example os , sys or any third-party) as a callable (with a __call__ method). 当您尝试将模块对​​象(例如ossys或任何第三方)用作可调用对象(使用__call__方法)时,将引发错误'module' object is not callable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM