django-admin startapp myapp
接著修改myapp內的views.py
from django.http import HttpResponse # Create your views here. def myapp_hellow(request): return HttpResponse("Hi, welcome to my app!")接著到Project的settings.py找到INSTALLED_APPS新增App進去
INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp' )
再到Project的urls.py新增url
from django.conf.urls import include, url from django.contrib import admin from myapp.views import myapp_hellow urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^test/$', myapp_hellow) ]
啟動伺服器就可以看到結果啦
執行結果: