zoukankan      html  css  js  c++  java
  • (三)django--带Template的网站

    我们接着(二),在new下新建一个templates(注意必须是这个名字,不然要进行配置),然后在该目录下新建一个test.html

     2.我们在pycharm中新建的html文件里面不会有内容,我们输入!,然后按tab,就会自动生成一个简单的html页面

     我们简单的在里面加个<h1></h1>

    3.我们配置news中的views.py和urls.py

    views.py

    from django.shortcuts import render
    
    # Create your views here.
    from django.http import HttpResponse
    def index(request):
        return render(request,'test.html')

    urls.py

    from django.contrib import admin
    from django.urls import path
    from . import views
    
    urlpatterns = [
        path('',views.index),
    ]

    4.配置myweb中的urls.py

    from django.contrib import admin
    from django.urls import path,include
    from news import urls
    
    urlpatterns = [
        path('admin/', admin.site.urls),
        path('', include(urls)),
    ]

    5.最后运行

    python manage.py runserver

     总结,具体的流程是:myweb中的urls.py--news中的urls.py--news中的views.py中的index函数--test.html

  • 相关阅读:
    ecmall 开发一个新模块
    ecmall 如何新增挂件
    ecmall 主从表的4种模型关系
    ecmall 的一些方法说明
    ecmall 支付成功 订单状态没有改变解决办法
    ecmall 基础类分析
    phpcms 新建模块安装
    phpcms pc_base::load
    strptime()方法
    GDB调试方法精粹
  • 原文地址:https://www.cnblogs.com/xiximayou/p/11693776.html
Copyright © 2011-2022 走看看