1

I am running a django project off of an Ubuntu Server 14.04, the web page is up and running, however when the page loads, there is no CSS, or format at all, it just looks like plain HTML. I know for sure that the admin page has a style and aesthetic, and even that looks like plain HTML. What did I do wrong? Maybe I didn't collect the static files correctly?

Picture of the page: enter image description here

Not sure why this is happening

Apache error.log:

enter image description here

M. Barbieri
  • 512
  • 2
  • 13
  • 27
  • Yeah I did a collecstatic, and the files are on the server – M. Barbieri May 19 '16 at 03:37
  • interestingly enough though not all the files that was under templates were transferred over to the static directory. – M. Barbieri May 19 '16 at 03:38
  • I actually just noticed something. If I do a runserver on the django app and access the localhost, when I use http port the static files aren't found. However, when I do 127.0.0.1:8000 the admin page looks fine....what's that about? – M. Barbieri May 19 '16 at 03:40
  • Look. At. The. URL. Is it mapping to *anything* that either the Apache server (via the Django urls.py file(s)) or (possibly) the front-end nginx server is handling? – Peter Rowell May 19 '16 at 03:44
  • Yes it maps to '/login/?next=/' as soon as I put the IP in my browser. – M. Barbieri May 19 '16 at 03:50
  • Could it be because in my apache config file I have it listening for port 8000? – M. Barbieri May 19 '16 at 03:54
  • I am using apache and mod_wsgi, why? is that not recommended? – M. Barbieri May 19 '16 at 03:54
  • no that's fine. For a moment I was confused if you were using manage.py ignore that comment. What does the error log on apache or maybe even chrome developer console say about the missing files? – e4c5 May 19 '16 at 04:10
  • 1
    Please provide details on how you setup Apache to handle serving up static files. That is, what steps did you do as documented in https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/#serving-files – Graham Dumpleton May 19 '16 at 04:17
  • @e4c5 I added an error.log, sorry for the delay, I just saw the comment – M. Barbieri May 19 '16 at 15:33

2 Answers2

1

did you set the STATIC_ROOT in your projects settings , then make collect static and add the folder name in apache conf.

eg :

STATIC_URL = '/static/'
STATIC_ROOT = root("statticstorage")

then if run python manage.py collect static the command will create a folder called static storage and all the styles (including admin css and etc) will copied from static folder , then make the root in to static storage in apache conf

  • Thanks for the response! I already have a static directory in the root of my app. When you say "make the root in to static storage in apache conf" do you mean go into the apache.conf and type in the line "DocumentRoot /path/to/static/dir"? – M. Barbieri May 19 '16 at 14:43
1

I realized that I was mapping the static files incorrectly in apache.conf

The correct map to the files would be: Alias /static /var/www/html/myproject/static

Note: Need to make sure that /static doesn't have a trailing slash in the above command

M. Barbieri
  • 512
  • 2
  • 13
  • 27