Django 创建APP - 简单路由系统案例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Django 创建APP - 简单路由系统案例相关的知识,希望对你有一定的参考价值。
架构图:
setting.py:
INSTALLED_APPS = [ ... ‘bootstrap‘, ]
myapp -> myapp -> urls.py
from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ url(r‘^admin/‘, admin.site.urls), url(r‘^bootstrap/‘, include(‘bootstrap.urls‘)), ]
myapp -> bootstrap -> urls.py
from django.conf.urls import url from . import views urlpatterns = [ url(r‘^$‘, views.index, name=‘index‘), url(r‘^helloworld/‘, views.helloworld, name=‘helloworld‘), ]
myapp -> bootstrap -> views.py
from django.shortcuts import render # Create your views here. from django.http import HttpResponse def helloworld(request): return HttpResponse("Hello world") def index(request): return HttpResponse("Hello, world. You‘re at the polls index.")
截图一: index
截图二: helloworld
以上是关于Django 创建APP - 简单路由系统案例的主要内容,如果未能解决你的问题,请参考以下文章