Running Debian on Virtual Machine guest inside Windows host. Set Bridged for adapter-type. Installed Django on the guest and using build-in runserver
and built-in database for testing purposes.
Having simple files structure:
> ..
> templates
> base.html
> static
> css
> base.css
> manage.py
> setting.py
> ..
File settings.py
:
STATIC_URL = '/static/'
File base.html
:
{% load static %}
...
<link rel="stylesheet" href="{% static 'css/base.css' %}">
Getting error, not found:
GET http://192.168.XX.XX:8000/static/css/base.css
Debug
in settings.py
is set to true (means static files should be surved). The link looks correct. Now why doesn't this work?
Edit: looks like I forgot to run 'collectstatic'. Here is the output after running it:
Edit2:
EXTERNAL_APPS = [
..
'django.contrib.staticfiles',
]
PROJECT_NAME = 'fooproject'
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, PROJECT_NAME, 'staticfiles')
STATIC_URL = '/static/'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…