3 回答

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

TA貢獻1801條經驗 獲得超16個贊
在生產環境中,靜態文件由 Web 服務器(apache、nginx)提供
在開發中,如果您使用 django.contrib.staticfiles 并且 DEBUG 設置為 True,則 app_name/static/app_name 中的文件將自動提供。
如果文件是由用戶在您的網絡應用程序中上傳的,您需要編輯您的基本 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貢獻1830條經驗 獲得超3個贊
抱歉各位,這是一個拼寫錯誤。我真是太笨了....
在設置.py
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'the7thstreet/static'),
'/var/www/static',
]
已更正
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
'/var/www/static',
]
- 3 回答
- 0 關注
- 172 瀏覽
添加回答
舉報