Reputation: 113
I have been trying to get Apache22 serve static files for my Django1.8 application. I got mod_wsgi working to serve my application; however, once it does the css and js files are not present.
This is my settings static items:
STATIC_URL = '/static/'
STATIC_ROOT = 'C:/Users/name/Documents/app/DRF/app/static'
STATICFILES_DIRS = (
('assets', 'C:/Users/name/Documents/app/DRF/app/public'),
)
This is what I have in my Apache config file:
<VirtualHost *:80>
Alias /static/assets/ "C:/Users/name/Documents/app/DRF/app/public"
<Directory "C:/Users/name/Documents/app/DRF/app/public">
Order deny,allow
Allow from all
</Directory>
#WSGIScriptAlias...
#....more
</VirtualHost>
And in my template I have :
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static "assets/css/style.css" %}"></script>
When I manually go to the URL, 127.0.0.1/static/assets/css/style.css
it just serves the default HTML page. Almost as if it cannot find the the route for that CSS file so it serves the default page again.
Any help is appreciated, thanks in advance.
Upvotes: 0
Views: 75
Reputation: 58523
Try changing:
Alias /static/assets/ "C:/Users/name/Documents/app/DRF/app/public"
to:
Alias /static/assets/ "C:/Users/name/Documents/app/DRF/app/public/"
You must match the trailing slash on URL and file path if you are going to add a slash.
So, either on both, or not on either.
Upvotes: 1