摘要: 1、将css代码单独用文件保存 新建kbrequest/static/css/index.css文件 将原型HTML文件中的style标签中所有css代码复制到该文件 在index.html添加引用外部css文件代码 2、将js代码单独用文件保存 新建kbrequest/static/js/inde 阅读全文
posted @ 2025-12-24 17:07 省时哥 阅读(8) 评论(0) 推荐(0)
摘要: 1、编写视图函数 # kbrequest/views.py from django.shortcuts import render from django.views import generic def index(request): return render(request, "kbreque 阅读全文
posted @ 2025-12-24 15:37 省时哥 阅读(5) 评论(0) 推荐(0)
摘要: 1、创建项目创建应用 2、注册应用、修改语言设置 # kbmgr/settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django. 阅读全文
posted @ 2025-12-24 15:28 省时哥 阅读(4) 评论(0) 推荐(0)
摘要: 1、描述需求,让AI生成网站原型 阅读全文
posted @ 2025-12-24 15:14 省时哥 阅读(1) 评论(0) 推荐(0)
摘要: 1、创建静态文件目录 创建目录polls/static/polls 2、创建一个css文件 在polls/static/polls创建style.css # polls/static/polls/style.css li a { color: green; } 3、在模板文件顶部引用css文件 # 阅读全文
posted @ 2025-12-24 15:04 省时哥 阅读(2) 评论(0) 推荐(0)
摘要: 1、改良URLconf # polls/urls.py from django.urls import path from . import views app_name = "polls" urlpatterns = [ path("", views.IndexView.as_view(), na 阅读全文
posted @ 2025-12-24 14:30 省时哥 阅读(4) 评论(0) 推荐(0)
摘要: 1、给URL名称添加命名空间 from django.urls import path from . import views app_name = "polls" #添加命名空间 urlpatterns = [ path("", views.index, name="index"), path(" 阅读全文
posted @ 2025-12-24 13:26 省时哥 阅读(1) 评论(0) 推荐(0)
摘要: 1、修改detail视图函数 # polls/views.py from django.shortcuts import render, get_object_or_404 def detail(request, question_id): question = get_object_or_404( 阅读全文
posted @ 2025-12-24 11:27 省时哥 阅读(1) 评论(0) 推荐(0)
摘要: 1、创建html文件 # polls/templates/polls/index.html {% if latest_question_list %} <ul> {% for question in latest_question_list %} <li> <a href="/polls/{{ qu 阅读全文
posted @ 2025-12-24 11:20 省时哥 阅读(4) 评论(0) 推荐(0)
摘要: 1、改写index()视图函数 让这个视图函数可以展示数据库按发布日期排序后的最近5个投票问题,以空格分割 # polls/views.py 修改index视图函数 from .models import Question def index(request): latest_question_li 阅读全文
posted @ 2025-12-24 11:03 省时哥 阅读(2) 评论(0) 推荐(0)
摘要: 1、添加视图 # polls/views.py from django.http import HttpResponse def index(request): return HttpResponse("你好,这里是投票应用主页") def detail(request, question_id): 阅读全文
posted @ 2025-12-24 10:56 省时哥 阅读(3) 评论(0) 推荐(0)
摘要: 1、创建一个管理员账号 python manage.py createsuperuser 运行以上命令输入账号、邮箱、密码、确认密码即可创建管理员账号 2、启动开发服务器访问管理站点页面 python manage.py runserver 在浏览器访问http://127.0.0.1:8000/a 阅读全文
posted @ 2025-12-24 10:41 省时哥 阅读(7) 评论(0) 推荐(0)