07 2022 档案

Django当中使用数据库锁
摘要:如何在Django当中使用数据库锁呢?局部事务锁。通过上下文管理。 # 事务 with transaction.atomic(): # 在数据库中加锁 select * from customer where id in [11,22] for update origin_queryset = mo 阅读全文

posted @ 2022-07-31 18:48 一先生94 阅读(491) 评论(0) 推荐(0) 编辑

Django当中models中的limit_choices_to
摘要:在models.Model中会遇到 limit_choices_to ,这个是什么意思呢? 在使用ModelForm渲染前端页面的时候,当model字段为ForeignKey的时候,会被渲染成select单选框, model字段为ManyToMany的时候会被渲染成多选select款。 当你在mod 阅读全文

posted @ 2022-07-31 11:20 一先生94 阅读(667) 评论(0) 推荐(0) 编辑

Django当中自己定义写一个分页器
摘要:在python当中自己写一个分页器,而不是直接运用Django中的分页器组件。 1.py 1 """ 2 分页组件 3 """ 4 5 6 class Pagination(object): 7 def __init__(self, current_page, all_count, base_url 阅读全文

posted @ 2022-07-29 10:54 一先生94 阅读(31) 评论(0) 推荐(0) 编辑

Django如何从Model中获取字段名称——verbose_name
摘要:# models.pyfrom django.db import models # Create your models here. class UserInfo(models.Model): name = models.CharField(max_length=32,verbose_name='用 阅读全文

posted @ 2022-07-28 21:01 一先生94 阅读(867) 评论(0) 推荐(0) 编辑

Django当中如何实现文件的上传的几种方法
摘要:在Django当中需要进行文件的上传,那么有哪几种方式呢?自己总结了下,有如下几种方法。 方式一:基于form表单进行上传。 index.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>xx</t 阅读全文

posted @ 2022-07-28 08:49 一先生94 阅读(3692) 评论(0) 推荐(0) 编辑

Django---inclusion_tag的使用
摘要:Django当中的inclusion_tag,来源于 from django.template import Library 属于Library下的一个方法。 主要作用:通过渲染一个模板来显示一些数据。属于自定义标签的一种。 项目实现:为了能够在页面中一栏上显示一级菜单 1.templatetags 阅读全文

posted @ 2022-07-27 16:49 一先生94 阅读(176) 评论(0) 推荐(0) 编辑

Django当中request.path, request.path_info, get_full_path方法的区别
摘要:url : http://127.0.0.1:8001/rbac/role/edit/?page=2 1.request.path: request.path仅提供相对于根目录的url相对路径,不包含参数。它的输出是一个字符串,结果如下所示:/rbac/role/edit/ 2.request.pa 阅读全文

posted @ 2022-07-27 13:37 一先生94 阅读(621) 评论(0) 推荐(0) 编辑

Django3.2自动获取项目中的全部URL
摘要:import refrom collections import OrderedDictfrom django.conf import settingsfrom django.utils.module_loading import import_stringfrom django.urls.reso 阅读全文

posted @ 2022-07-25 18:35 一先生94 阅读(199) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示