python - Django admin not serving static files? -


django 1.6

i'm having trouble serving static files django admin.

urls.py:

urlpatterns = patterns('',     url(r'^$', 'collection.views.index', name='home'),     url(r'^collection/', include('collection.urls')),     url(r'^admin/',    include(admin.site.urls)), )  if settings.debug:     urlpatterns += patterns('',         url(r'^media/(?p<path>.*)$', 'django.views.static.serve', {             'document_root': settings.media_root,         }),         url(r'^static/(?p<path>.*)$', 'django.views.static.serve', {             'document_root': settings.static_root,         }), ) 

settings.py

... media_root = '/users/me/projectdir/media/' media_url = 'media/'  static_root = '/users/me/projectdir/static/' static_url = 'static/' ... 

template (base.html)

<!doctype html> <html lang='en-us'> <head> <title>mysite</title>  {% load static %} {% block links %}     <link href="{% static 'css/bootswatch-simplex.css' %}" rel="stylesheet" type="text/css">     <link href="{% static 'css/custom.css' %}" rel="stylesheet" type="text/css">     <link rel="shortcut icon" href="{% static "favicon.ico" %}"> {% endblock %}  <script src="{% static "lib/bootstrap-3.1.1-dist/js/bootstrap.js" %}"></script> <script type="text/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{% static "admin/" %}{% endfilter %}";</script> </head> ... 

django serving admin ok, without static files: css, js, etc.

static files public-facing pages work fine.

if change static_url '/static/', opposite true: admin fine, public pages lose static files.

here's weirdest part. if "view source" of admin pages in browser, shows correct url static pages, example:

/static/admin/css/base.css 

but if follow link, changes this:

http://localhost:8000/admin/static/admin/css/base.css 

i think it's checking static files relative localhost:8000/admin/static/ instead of localhost:8000/static/. adds "admin" level url, static part of domain. can't figure out how rid of it.

i have tried collectstatic, doesn't help. static files in static directory, they're not being served. can type in, say, http://localhost:8000/static/admin/css/base.css , right css file (in plaintext). files there. bet wrong configuration.

i've emptied caches, restarted dev server, etc. no beans.

ideas?

use django-admin.py collectstatic or go ~/django/contrib/admin/static , copy admin folder(which contains static files) , paste them project's static directory.

**edit**

a desperate or clumsy solution can try for: change static_url '/static/', question saw this:

if change static_url '/static/', opposite true: admin fine, public pages lose static files.

then check inspect element/firebug, see urls being served in public pages. '/' missing or added '/'. adjust it, , see if works.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -