2
<head>
<title>My website</title>
<meta charset="utf-8">
{% load static from staticfiles %}
<link type="text/css" rel="stylesheet" href="{% static "mysite/css/base.css" %}" />
</head>

thats what i use in my template. Everything is fine when debug sets true, but when i flip it to false, and set allowed_hosts to '*' (for testing), the css and static files are not working..

John
  • 190
  • 1
  • 4
  • 15
  • 2
    `ALLOWED_HOSTS` is a list, you cannot set it to `*` and expect things to work. – Burhan Khalid Aug 06 '13 at 19:48
  • I agree he should have been explicit, but I assumed he allowed `*` correctly, otherwise everything would be broken and not just static files. Could it be this? http://stackoverflow.com/a/17163948/1081569 – Paulo Almeida Aug 06 '13 at 19:52
  • 1
    Django's staticfiles does not serve statisch in production mode. You have to configure Apache/Nginx for serving those. You might be able to do that through Django, but that's against best practices. – Bouke Aug 06 '13 at 19:52
  • Hi Burhan, this is excerpt from Django 1.5 documentation. "A value of '*' will match anything; in this case you are responsible to provide your own validation of the Host header". I mean it works..it loads my page but doesnt load the css and other static files. – John Aug 06 '13 at 19:52
  • @John, but do you have `ALLOWED_HOSTS = ['*']`? – Paulo Almeida Aug 06 '13 at 19:54
  • bouke, you might be right. those codes in template might not work in production mode...Thanks. – John Aug 06 '13 at 19:54

0 Answers0