国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

django訪問(wèn)靜態(tài)web資源

2019-11-10 20:43:53
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

使用django訪問(wèn)如html這些頁(yè)面,或者引入其他東西時(shí)就需要配置靜態(tài)web資源了;

只需要修改urls.py即可

"""PRoject URL ConfigurationThe `urlpatterns` list routes URLs to views. For more information please see:    https://docs.djangoproject.com/en/1.10/topics/http/urls/Examples:Function views    1. Add an import:  from my_app import views    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')Class-based views    1. Add an import:  from other_app.views import Home    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')Including another URLconf    1. Import the include() function: from django.conf.urls import url, include    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))"""from django.conf.urls import urlfrom django.contrib import adminfrom project.views import hello,search,search_post,Ajax_post,requests_test,uifrom django.conf import settings# static filesimport osfrom django.conf.urls.static import staticurlpatterns = [    url(r'^hello/', hello),	url(r'^search/', search),	url(r'^search_post/', search_post),	url(r'^ajax_post/', ajax_post),	url(r'^requests_test/', requests_test),	url(r'^ui/', ui),	]''' 訪問(wèn)靜態(tài)web資源配置 start '''if settings.DEBUG:	media_root = os.path.join(settings.BASE_DIR,'templates')	urlpatterns += static('/templates/', document_root=media_root)''' 訪問(wèn)靜態(tài)web資源配置 end '''

我的目錄結(jié)構(gòu):

訪問(wèn)結(jié)果:

也還有其他的方法可以配置,有時(shí)間的話可以試試其他的


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 雷山县| 揭阳市| 南城县| 永吉县| 泗阳县| 昆明市| 许昌县| 朝阳区| 松江区| 宣化县| 灵璧县| 南康市| 海门市| 原平市| 沾益县| 垦利县| 教育| 南昌县| 岢岚县| 方正县| 偏关县| 新昌县| 铅山县| 丰都县| 紫阳县| 崇明县| 抚宁县| 都兰县| 邯郸县| 淳化县| 遂宁市| 分宜县| 安康市| 如东县| 古蔺县| 闻喜县| 托里县| 集贤县| 密云县| 广灵县| 呼图壁县|