https://docs.djangoproject.com/zh-hans/3.1/ref/models/fields/#field-options字段类型AutoField自动增长的IntegerField,通常不用指定,不指定时Django会自动创建属性名为id的自动增长属性。BooleanField布尔字段,值为True或False。NullBooleanField支持Null、Tr...
别把酒留在杯里,别把话放在心里
https://docs.djangoproject.com/zh-hans/3.1/ref/models/fields/#field-options字段类型AutoField自动增长的IntegerField,通常不用指定,不指定时Django会自动创建属性名为id的自动增长属性。BooleanField布尔字段,值为True或False。NullBooleanField支持Null、Tr...
raise ImproperlyConfigured('mysqlclient 1.4.0 or newer is required; you have %s.' % Database.__version__)django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required; you hav...
配置应用下的admin.pyfrom django.contrib import admin from booktest.models import BookInfo, HeroInfo class BookInfoAdmin(admin.ModelAdmin): """图书模型管理类""" # 自定义显示哪些字...
定义1.定义模型类:from django.db import models # Create your models here. # 定义一个模型类,表名BookInfo,继承models.Model class BookInfo(models.Model): # # id字段,不写也可以,默认就会有id字段 # id = models.AutoField(prima...
串行执行程序import time import random def producer(): res = [] for i in range(9999990): res.append(i) return res def consumer(c): x = 0 for i in c: x += i retu...
settings.py配置三个部分# 添加内置标签配置 TEMPLATES = [ { ...... 'OPTIONS': { ...... 'builtins': ['django.templatetags.static'] }, }, ] # 配置静态文件url路径 STAT...
默认html转义是开启的,比如<h1>ok<h1>会被转成<h1>ok</h1>。在网页中所见即所得{"content": "<h1>ok<h1>"}1.过滤器关闭转义{{ content | safe }} {# 在网页中显示的是h1标题 #}2.标签关闭转义{% autoescape...
父模版<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{% block title %} 默认 {% endblock %}</title> </head> &l...
1.变量普通变量: x = 'ok' {{ x }} 字典:d1 = {"name": "zs"} {{ d1.name }} 列表: l1 = [0,1,2,3,4] {{ l1.0 }} 2.if判断<!-- 也可以if in xxx--> {% if score < 60 %} <p>成绩不及格<...
app_name和namespace介绍https://www.liujiangblog.com/course/django/1361.配置根url# 指定包含的url为tpl.urls,app_name为tpl,命名空间为"tpl" path('', include(('tpl.urls', 'tpl'), namespace="tpl")) # ...