Set a static file on django

时间:2023-03-09 18:24:44
Set a static file on django
    1. In setting file:
ROOT_PATH='/home/ronglian/project/taskschedule'
STATIC_URL = '/static/'
STATICFILES_DIRS=(
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
os.path.join(ROOT_PATH,'static'),
)
STATIC_ROOT= ''
2. In above of urls.py file : from django.contrib.staticfiles.urls import staticfiles_urlpatterns
3. Add urlpatterns in urls.py file:
urlpatterns +=staticfiles_urlpatterns() 4. In the project directory, make a new directory file named 'static', the add the css and jquery file in it.