1. Make sure that django.contrib.staticfiles is included in your INSTALLED_APPS2. also if it already included,
adding the following snippet to your urls.py:-----------------------------------------------------------------------------------------------------------------------
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# others urls,
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
-----------------------------------------------------------------------------------------------------------------------
3. also in your settings.py adding STATIC_ROOT, make sure you have "pathlib" imported above:
-----------------------------------------------------------------------------------------------------------------------
from pathlib import Path
# ...
# ... other code
# ...
STATIC_URL = "static/"
STATIC_ROOT = Path.joinpath(BASE_DIR, STATIC_URL)
-----------------------------------------------------------------------------------------------------------------------
or if you prefer os module adding this instead in settings.py
-----------------------------------------------------------------------------------------------------------------------
import os
# ...
# ... other code
# ...
STATIC_URL = "static/"
STATIC_ROOT = os.path.join(BASE_DIR, STATIC_URL)
-----------------------------------------------------------------------------------------------------------------------
Although this is not suitable for production, only for development.
I hope this help.
ในวันที่ วันเสาร์ที่ 27 พฤษภาคม ค.ศ. 2023 เวลา 23 นาฬิกา 28 นาที 21 วินาที UTC+7 Ramesh Parajuli เขียนว่า:
Please help me: