Python 使用Django 1.4在调试中提供静态文件非常令人沮丧

Python 使用Django 1.4在调试中提供静态文件非常令人沮丧,python,django,static-files,Python,Django,Static Files,我喜欢Django,但在开发过程中获取静态文件是一件痛苦的事情。我安装了webassets以使工作更轻松。基本上,我的资产是404'与我的当前配置,但管理资产是罚款(?!)。我的项目布局是这样的 myapp/ common/ static/ bootstrap/ img/ less/ js/ templates/ __in

我喜欢Django,但在开发过程中获取静态文件是一件痛苦的事情。我安装了webassets以使工作更轻松。基本上,我的资产是404'与我的当前配置,但管理资产是罚款(?!)。我的项目布局是这样的

myapp/
    common/
        static/
            bootstrap/
                img/
                less/
                js/
        templates/
        __init__.py
        assets.py
        urls.py
        models.py
        views.py
    projects/
        templates/
        static/
        __init__.py
        assets.py
        urls.py
        models.py
        views.py
    public/ <- (static files collected here)
settings.py
urlpatterns = patterns('',
    url(r'^projects/', include('myapp.projects.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', include('myapp.common.urls')),
)

urlpatterns += staticfiles_urlpatterns()
我的URL是这样配置的

myapp/
    common/
        static/
            bootstrap/
                img/
                less/
                js/
        templates/
        __init__.py
        assets.py
        urls.py
        models.py
        views.py
    projects/
        templates/
        static/
        __init__.py
        assets.py
        urls.py
        models.py
        views.py
    public/ <- (static files collected here)
settings.py
urlpatterns = patterns('',
    url(r'^projects/', include('myapp.projects.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', include('myapp.common.urls')),
)

urlpatterns += staticfiles_urlpatterns()
同样,assets.py看起来相当标准

from django_assets import register, Bundle

js = Bundle(
    'bootstrap/js/bootstrap-alert.js',
    'bootstrap/js/bootstrap-button.js',
    'bootstrap/js/bootstrap-carousel.js',
    'bootstrap/js/bootstrap-collapse.js',
    'bootstrap/js/bootstrap-modal.js',
    'bootstrap/js/bootstrap-popover.js',
    'bootstrap/js/bootstrap-scrollspy.js',
    'bootstrap/js/bootstrap-tab.js',
    'bootstrap/js/bootstrap-tooltip.js',
    'bootstrap/js/bootstrap-transition.js',
    'bootstrap/js/bootstrap-typeahead.js',
    output='bootstrap/script.js',
    debug=False
)

register('js', js)
我的基本模板非常基本

{% load assets %}
{% assets 'js' %}
    <script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
{%load assets%}
{%assets'js%}
{%endassets%}
因此,当runserver运行时,所有的js文件都被捆绑到一个标签中,标签的url
http://localhost:8000/static/bootstrap/script.js?ed501ad2
。但是这个404带有“bootstrap/script.js无法找到”的消息

但是,如果我登录到/admin应用程序,那么所有css资产都会正确呈现。我已经运行了collectstatic并验证了这些资产确实位于
public/
目录中


我在这里遗漏了什么?

您是否按照django assets文档中的要求将
django\u assets.finders.AssetsFinder
添加到您的
静态文件\u finders


非常感谢!我没有意识到这一点——我应该更仔细地阅读文档!克劳德:我认为这样的评论没有帮助。丹尼,你说得对,但是我开始对人们在没有阅读文档或谷歌搜索的情况下就发布问题感到恼火,这是一个不断增长的趋势。我只是觉得这对SO社区没有任何好处。在一个专业的环境中,任何人都会羞于问这样的问题,而且会在浪费同事的时间之前做家庭作业,我不认为在这里做同样的事情是可以的。