国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 伊宁县| 呼和浩特市| 勐海县| 慈溪市| 襄樊市| 黎平县| 读书| 丘北县| 建始县| 肇庆市| 平舆县| 美姑县| 浮山县| 武陟县| 隆昌县| 甘肃省| 东阳市| 桦川县| 鲁甸县| 陈巴尔虎旗| 抚顺市| 阜城县| 宜宾县| 房山区| 秀山| 钟祥市| 万盛区| 古浪县| 兴文县| 资源县| 喀喇| 施甸县| 昭苏县| 门源| 黔西| 彭州市| 东莞市| 绥棱县| 东兰县| 鞍山市| 玉龙|