标签:前端 templates 创建 template site str response test 定义
INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.staticfiles‘, ‘django_test.apps.DjangoTestConfig‘ ]
from django.shortcuts import render # Create your views here. from django.http import HttpResponse def index(request): return HttpResponse(‘欢迎来到Gaidy博客‘)
from django.conf.urls import url from . import views urlpatterns = [ # 这边定义子应用的路由 url(r‘index/$‘,views.index) ]
from django.conf.urls import url,include from django.contrib import admin import django_test.urls urlpatterns = [ url(r‘^admin/‘, admin.site.urls), url(r‘‘,include(django_test.urls)) ]
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Gaidy</title> </head> <body> 这是一个页面 </body> </html>
from django.shortcuts import render # Create your views here. from django.http import HttpResponse from django.shortcuts import render def index(request): return render(request, ‘index.html‘) # return HttpResponse(‘欢迎来到Gaidy博客‘)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Gaidy</title> </head> <body> {{ string }} </body> </html>
from django.shortcuts import render # Create your views here. from django.http import HttpResponse from django.shortcuts import render def index(request): date = "我是来自北方的一条狼" return render(request, ‘index.html‘, {"string":date}) # return HttpResponse(‘欢迎来到Gaidy博客‘)
标签:前端 templates 创建 template site str response test 定义
原文地址:https://www.cnblogs.com/gaidy/p/9248535.html