标签:src pat view .com highlight closed short img 配置
1 第一部分目录详解
修改django的项目当中的url中的配置:
from django.contrib import admin from django.conf.urls import url from django.urls import path from django.shortcuts import HttpResponse def home(request): return HttpResponse(‘<h1>hello</h1>‘) urlpatterns = [ url(r‘^admin/‘, admin.site.urls), url(r‘^h.html/‘, home), ]
需要输入对应的页面才可以访问
#2 部分 创建APP
建议做django的时候 在比较干净的目录做,不要目录嵌套目录
创建app
D:\Document\Python0404\Django0425>python manage.py startapp cmdb
D:\Document\Python0404\Django0425>python manage.py startapp openstack
创建完后进行一定的修改,将之前放在根下的url文件中内容进行修改:
修改如下:D:\Document\Python0404\Django0425\Django0425\urls.py
from django.contrib import admin from django.conf.urls import url from django.urls import path from cmdb import views urlpatterns = [ url(r‘^admin/‘, admin.site.urls), url(r‘^h.html/‘, views.home), ]
修改D:\Document\Python0404\Django0425\cmdb\views.py
from django.shortcuts import HttpResponse def home(request): return HttpResponse(‘<h1>hello This is CMDB</h1>‘)
标签:src pat view .com highlight closed short img 配置
原文地址:https://www.cnblogs.com/nodchen/p/8948265.html