這篇文章詳解python在pychram中利用djingo開發helloword
首先安裝pycheam,python,djingo。
在pychram中新建一個djingo專案
#在web2目錄下新建views.py文件,目錄如下:
接下來在views.py檔中寫helloworld程式碼:
# -*- coding: utf-8 -* from django.http import HttpResponse def hello(request): return HttpResponse("Hello world! This is my first trial. [笔记]")
還需要設定urls.py檔完成映射
from django.conf.urls import patterns, include, url from web2.views import hello from django.contrib import admin from django.conf.urls import * admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'web2.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), ('^hello/$', hello), )
一定要先匯入hello
#from web2.views import hello
然後啟動項目,在瀏覽器開啟
http://127.0.0.1:8000/hello/
#以上是詳解python在pychram中利用djingo開發helloword的詳細內容。更多資訊請關注PHP中文網其他相關文章!