上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 39 下一页
摘要: BigAutoField(AutoField): bigint 自增列,必须填入参数 primary_key=True 如果没有写自增列,则会自动创建一个列名为 id 的列 SmallIntegerField(IntegerField): 短整型,-32768 到 32767 PositiveSma 阅读全文
posted @ 2019-08-01 19:39 Sch01aR# 阅读(266) 评论(0) 推荐(0) 编辑
摘要: AutoField: int 自增列,必须填入参数 primary_key=True 如果没有写 AutoField,则会自动创建一个列名为 id 的列 from django.db import models class Person(models.Model): id = models.Auto 阅读全文
posted @ 2019-08-01 18:38 Sch01aR# 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 命名 URL: test.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>测试页面</title> </head> <body> <p>测试页面</p> <form action="/test/" 阅读全文
posted @ 2019-08-01 15:45 Sch01aR# 阅读(229) 评论(0) 推荐(0) 编辑
摘要: URL 配置: urls.py 中的基本配置: from django.conf.urls import url from app01 import views urlpatterns = [ url(正则表达式, views 视图函数[, 参数, 别名]), ] 在 Django 2 版本后将 u 阅读全文
posted @ 2019-07-31 17:21 Sch01aR# 阅读(285) 评论(0) 推荐(0) 编辑
摘要: 用 json 模块和 HttpResponse 返回生成的 json views.py: from django.shortcuts import render, HttpResponse import json # json 测试 def json_test(request): data = {" 阅读全文
posted @ 2019-07-30 20:30 Sch01aR# 阅读(1874) 评论(0) 推荐(1) 编辑
摘要: request.method: 获取请求的方法,例如 GET、POST 等 views.py: from django.shortcuts import render, HttpResponse # request 对象 def test(request): print(request.method 阅读全文
posted @ 2019-07-30 18:27 Sch01aR# 阅读(1331) 评论(0) 推荐(0) 编辑
摘要: FBV: Function Base View,基于函数的视图 views.py: from django.shortcuts import render, HttpResponse # FBV def upload(request): if request.method == "POST": fi 阅读全文
posted @ 2019-07-30 17:50 Sch01aR# 阅读(219) 评论(0) 推荐(0) 编辑
摘要: upload.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>上传页面</title> </head> <body> <form action="/upload/" method="post" e 阅读全文
posted @ 2019-07-30 17:32 Sch01aR# 阅读(337) 评论(0) 推荐(0) 编辑
摘要: simple_tag: simple_tag 和自定义 filter 类似,但可以接收更多更灵活的参数 在 app01/templatetags/ 目录下创建 mysimple_tag.py mysimple_tag.py: from django import template register 阅读全文
posted @ 2019-07-29 20:51 Sch01aR# 阅读(361) 评论(0) 推荐(0) 编辑
摘要: 静态文件的路径设置在 settings.py 中 如果该路径发生更改的话,html 中相关路径也要进行修改 CSS: <link href="/static/dashboard.css" rel="stylesheet"> 可以写成: {% load static %} <link href="{% 阅读全文
posted @ 2019-07-29 19:27 Sch01aR# 阅读(179) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 39 下一页