django 網站 Hello world

來源:互聯網
上載者:User

標籤:配置   產生   index   install   127.0.0.1   rtp   網站   str   url   

環境搭建

1、python2.7,python3.x均可以使用,

2、直接pip install django或者去下載whl檔案安裝

3、用eclipse和pycharm均可

 

開始

1、進入一個目錄(想存放項目的地方),然後目前的目錄中開啟cmd命令:"django-admin startproject myblog" 產生一些項目設定檔等

2、用eclipse開啟項目可以看到有幾個py檔案

3、cmd中cd進入到manage.py的同級目錄

4、敲入命令:"python manage.py runserver"即可啟動伺服器

5、在chrome中輸入"http://127.0.0.1:8000"可以看到"It works"畫面

6、依然在manage.py同級目錄,在cmd下,"python manage.py startapp blog",這樣就建立了一個應用blog

7、進行一些配置,在myblog下的urls.py中:

在settings.py中

在blog應用的views.py中

 

8、這樣,在runserver狀態下就可以訪問"http://127.0.0.1:8000/index"顯示"hello,world!"

 

django 網站 Hello world

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.