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()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)