无法在Django Python中提供CSS,JS等静态文件

无法在Django Python中提供CSS,JS等静态文件,第1张

无法在Django Python中提供CSS,JS等静态文件

base.html

{% load static %}<link rel="stylesheet" href="{% static 'css/personnel_blog_hm.css' %}" type="text/css">

设定

PROJECT_DIR  = os.path.dirname(__file__)MEDIA_ROOT = os.path.join(PROJECT_DIR,'media')MEDIA_URL = '/media/'STATIC_ROOT = os.path.join(PROJECT_DIR,'static')STATIC_URL = '/static/'STATICFILES_DIRS = (    # Put strings here, like "/home/html/static" or "C:/www/django/static".    # Always use forward slashes, even on Windows.    # Don't forget to use absolute paths, not relative paths.    os.path.join(PROJECT_DIR, 'staticfiles'),)

网址

from django.conf.urls.defaults import *from django.conf import settingsfrom django.contrib.staticfiles.urls import staticfiles_urlpatternsfrom django.conf.urls.static import staticfrom django.contrib import adminadmin.autodiscover()urlpatterns = patterns('',     url(r'^$', 'personnel_blog.views.home_page'),     url(r'^admin/', include(admin.site.urls)),)+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)urlpatterns += staticfiles_urlpatterns()


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5647239.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存