Django
Django
weixin_1019122782
这个作者很懒,什么都没留下…
展开
-
Django表单post请求
urls.py re_path(’^search_post$’, search.search_post), post.html 文件代码: {% csrf_token %} <p>{{ rlt }}</p> search2.py 文件代码: -- coding: utf-8 -- from djang...原创 2020-02-02 21:24:17 · 121 阅读 · 0 评论 -
Django表单get请求
创建一个 search.py 文件 -- coding: utf-8 -- from django.http import HttpResponse from django.shortcuts import render_to_response #使用 render_to_response可能会出错,可使用render #from django.shortcuts import render 表单...原创 2020-02-02 21:21:25 · 283 阅读 · 0 评论 -
Django数据库增删改查操作
-- coding: utf-8 -- from django.http import HttpResponse #调用Test模型类 from TestModel.models import Test def testdb(request): #数据库查询 获得所有数据行,相当于SQL中的SELECT * FROM result=Test.objects.all() filter相当于SQL中的...原创 2020-02-02 20:50:18 · 132 阅读 · 0 评论 -
Django 模板标签
f/else 标签 {% if condition1 %} … display 1 {% elif condition2 %} … display 2 {% else %} … display 3 {% endif %} for 标签 {% for athlete in athlete_list %} {{ athlete.name }} {% endfor %} ifequal/if...原创 2020-02-02 20:22:23 · 90 阅读 · 1 评论 -
Django安装
一、安装:pip install Django==3.0.2 二、pycharm创建项目 manage.py: 一个实用的命令行工具,可让你以各种方式与该 Django 项目进行交互。 …/init.py: 一个空文件,告诉 Python 该目录是一个 Python 包。 …/settings.py: 该 Django 项目的设置/配置。 …/urls.py: 该 Django 项目的 URL 声...原创 2020-02-02 20:20:44 · 93 阅读 · 0 评论