3 回答

TA貢獻1811條經驗 獲得超4個贊
在源周圍添加引號,如下所示
{% load static %} <img src="{% static 'images/mona.jpeg' %}" alt="Avatar" style="width:100%;">

TA貢獻1815條經驗 獲得超10個贊
在生產中,靜態文件由Web服務器(apache,nginx)提供
在開發中,如果您使用的是django.contrib.staticfiles并且DEBUG設置為True,則會自動提供app_name/static/app_name中的文件。
如果文件由用戶在 Web 應用中上傳,則需要編輯基本 urls.py 文件,如下所示
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
For more info on this see https://docs.djangoproject.com/en/3.0/howto/static-files/

TA貢獻1798條經驗 獲得超3個贊
對不起,伙計們,這是一個拼寫錯誤。太笨了...
在 settings.py
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'the7thstreet/static'),
'/var/www/static',
]
糾正
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
'/var/www/static',
]
添加回答
舉報