This question is similar to the questions asked here and here. However, solutions to both of them seem to be outdated with the current Django version (1.8).
My django project is running perfectly fine on the developnment server. Now I am trying to deploy it to production and the only trouble is that the css files being references in the default django admin view are not being referenced properly.
Here is what the default admin view is trying to locate it by :
http://localhost/static/admin/css/base.css
I am trying to follow the recommended approach given in django docs
We strongly recommend using django.contrib.staticfiles to handle the admin files (along with a Web server as outlined in the previous section; this means using the collectstatic management command to collect the static files in STATIC_ROOT, and then configuring your Web server to serve STATIC_ROOT at STATIC_URL).
Here is the snippet from my 000-default.conf file
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/testapp/
Alias /static/ /var/www/html/testapp/static
<Directory /var/www/html/testapp/static>
Require all granted
</Directory>
WSGIDaemonProcess sampleapp python-path=/var/www/html/testapp:/var/www /html/testapp/env/lib/python2.7/site-packages
WSGIProcessGroup sampleapp
and my STATIC_ROOT and STATIC_URL are configured as below:
STATIC_ROOT = '/var/www/html/testapp/static/'
STATIC_URL = '/static/'
I have collected the static files of django admin using the collectstatic command, still the files are not being served.
I am unable to figure out what is wrong with the setup.
UPDATE As per @Cheng 's comment I am attaching the lines from apache access log
127.0.0.1 - - [27/May/2015:18:36:16 +0530] "GET /static/admin/css/base.css HTTP/1.1" 404 512 "http://localhost/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0"
127.0.0.1 - - [27/May/2015:18:36:16 +0530] "GET /static/admin/css/login.css HTTP/1.1" 404 514 "http://localhost/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0"
WORKING SOLUTION Thanks to @Cheng, I got a solution to the problem. I further read in the docs to confirm the solution.
Note that if you include a trailing / on the URL-path then the server will require a trailing / in order to expand the alias. Likewise, if you omit the slash on the URL-path then you must also omit it from the file-path
If you closesly observe the snippet I had provided, I had missed the trailing slash in the file path.