Django 1.6
I am having trouble maintaining my static files for my 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 is for my admin, just without static files: CSS, JS, etc.
Static files for my open pages work fine.
If I change STATIC_URLto '/static/', the opposite is true: the administrator is fine, but my public pages are losing their static files.
Here's the weirdest part. If I "browse the source" of my admin pages in my browser, it shows the correct URL for static pages, for example:
/static/admin/css/base.css
But if I really follow the link, she changes it to this:
http://localhost:8000/admin/static/admin/css/base.css
, localhost:8000/admin/static/, localhost:8000/static/. "admin" URL-, static . , .
collectstatic, . , . , , http://localhost:8000/static/admin/css/base.css CSS ( ). . , - .
, dev- .. No beans.
?