开发者

Django serving static files for different folder

I my static folder I have admin, filebrowser, grappelli, and public.

public folder includes css, images and js, just like any folder in the static folder.

In my url.py :

    #Django-Grappelli
    url(r'^grappelli/', include('grappelli.urls')),

    #Django-Filebrowser
    url(r'^admin/filebrowser/', include('filebrowser.urls')),

     # Uncomment the next line to enable the admin:
     url(r'^admin/', include(admin.site.urls)),

    #Static
    url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
    'document_root': settings.STATIC_ROOT,
    }),

    #Public login
    url(r'^public/login/$', 'django.contrib.auth.views.login', {'template_name': 'public/login.html'}),

I am able to serve the static files without any problem, but how to serve the public folder files? #Public is conflicting with #Public login.

I add this into the url.py

开发者_开发技巧
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
        'document_root': settings.STATIC_ROOT,
    }),

Still no luck.

<link href="/static/public/css/forms.css" rel="stylesheet" type="text/css" />

The forms.css cannot be found.

[05/May/2011 09:30:37] "GET /static/public/css/forms.css HTTP/1.1" 404 1751


Try moving the login URL pattern above the static one. Currently it will try to find a static file named login.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜