I have searched the similar questions but did not find my answer.
My simple webapp structure is:
mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
static/
test.txt
myfirstapp/
I have set STATIC_URL = '/static/' and STATIC_ROOT = os.path.join(BASE_DIR, "static")
and when I start the django server, I print the static path out which is /home/pi/mysite/static, looks correct
In my template, the code is:
{% load static %}
<li><a href="{% static 'test.txt' %}">Test File</a></li>
If I click the link, I always got 404. However, if I put the static folder in /home/pi/mysite/mysite/, then the static dir is /home/pi/mysite/mysite/static, this code can work and I can view the txt file.
I am confused by the settings, and I thought I set the static directory in settings in the root directory but not in the "mysite/mysite". Why the real behavior is opposite? What is the problem here? Thanks!