随笔分类 -  Django

摘要:关联对象¶ 当你在模型中定义了关联关系(如 ForeignKey, OneToOneField, 或 ManyToManyField),该模型的实例将会自动获取一套 API,能快捷地访问关联对象。 拿本文开始的模型做例子,一个 Entry 对象 e 通过 blog 属性获取其关联的 Blog 对象: 阅读全文
posted @ 2019-12-28 16:30 random_lee 阅读(289) 评论(0) 推荐(0)
摘要:https://www.cnblogs.com/xjmlove/p/10087053.html 阅读全文
posted @ 2019-12-27 17:00 random_lee 阅读(658) 评论(0) 推荐(0)
摘要:原文链接 https://my.oschina.net/VASKS/blog/874270 django admin svg 不显示。后台显示 xx.svg 200 但浏览器就是不显示。 百度了一圈,没有一个正确答案。 谷歌上不上,哎,必应一下。 然后去了,stackoverflow http:// 阅读全文
posted @ 2019-10-29 14:36 random_lee 阅读(660) 评论(0) 推荐(0)
摘要:``` #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Henry 17607168727@163.com import calendar import datetime import time def return_time_stamp(): # 获取当天日期 today = datetime.datetime.t... 阅读全文
posted @ 2019-08-26 18:40 random_lee 阅读(889) 评论(0) 推荐(0)
摘要:通常,你想要发送一些编码为表单形式的数据——非常像一个 HTML 表单。要实现这个,只需简单地传递一个字典给 data 参数。你的数据字典在发出请求时会自动编码为表单形式: 你还可以为 data 参数传入一个元组列表。在表单中多个元素使用同一 key 的时候,这种方式尤其有效: 很多时候你想要发送的 阅读全文
posted @ 2019-08-23 13:58 random_lee 阅读(1008) 评论(0) 推荐(0)
摘要:python 2.7 1. codecs python官方文档中文翻译 使用给定模式打开编码文件,并返回提供透明编码/解码的打包版本。默认文件模式为“r”,表示以读取模式打开文件。 2. 使用 需要明确的知道 文件的编码格式 3. indent=4 缩进 4个空格 python 3 1. pytho 阅读全文
posted @ 2019-08-13 14:53 random_lee 阅读(3411) 评论(0) 推荐(0)
摘要:```python #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Henry 17607168727@163.com import sys import logging from logging.handlers import TimedRotatingFileHandler import os from subprocess im... 阅读全文
posted @ 2019-07-25 17:44 random_lee 阅读(1490) 评论(0) 推荐(0)
摘要:📓Python下划线命名模式 - 摘要 以下是我在本文中介绍的五个下划线模式在Python中的快速摘要或“备忘单”: 阅读全文
posted @ 2019-07-17 09:57 random_lee 阅读(257) 评论(0) 推荐(0)
摘要:pip python 依赖 安装 有时候, 需要部署 Python 应用的服务器没有网络连接, 这时候, 你就要把整个 Python 应用做成离线安装包. 借助 wheel, 很容易就可以实现. 首先, 你的开发机器上要安装 wheel: pip install wheel 接下来, 下载依赖包的 阅读全文
posted @ 2019-07-15 16:48 random_lee 阅读(10742) 评论(0) 推荐(1)
摘要:# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云(BlueKing) available. Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. Lic... 阅读全文
posted @ 2019-04-22 15:03 random_lee 阅读(263) 评论(0) 推荐(0)
摘要:# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云(BlueKing) available. Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. Lic... 阅读全文
posted @ 2019-04-21 13:10 random_lee 阅读(1911) 评论(0) 推荐(0)
摘要:# Create your models here. from django.db import models # name是表名,fields是字段,app_label是你的应用名(如:flow),module是应用下的模型(如:flow.models),options是元类选项 def crea 阅读全文
posted @ 2019-04-19 17:09 random_lee 阅读(3378) 评论(4) 推荐(0)
摘要:修改settings.py文件 # pip3 install pymysql 修改__init__.py 文件 views.py 代码路径 阅读全文
posted @ 2019-01-23 23:20 random_lee 阅读(502) 评论(0) 推荐(0)
摘要:template_filter_demo 过滤器相关: 一、形式:小写{{ name | lower }} 二、串联:先转义文本到HTML,再转换每行到 <p> 标签{{ my_text|escape|linebreaks }} 三、过滤器的参数显示前30个字{{ bio | truncatewor 阅读全文
posted @ 2019-01-22 22:50 random_lee 阅读(510) 评论(0) 推荐(0)
摘要:1 """template_url_demo URL Configuration 2 3 The `urlpatterns` list routes URLs to views. For more information please see: 4 https://docs.djangoprojec 阅读全文
posted @ 2019-01-22 15:55 random_lee 阅读(499) 评论(0) 推荐(0)
摘要:![](https://img2018.cnblogs.com/blog/1311333/201901/1311333-20190120234435944-1860004216.png) 阅读全文
posted @ 2019-01-20 23:45 random_lee 阅读(612) 评论(0) 推荐(0)
摘要:for...in...笔记: 标签: 类似于 中的 。可以遍历列表、元组、字符串、字典等一切可以遍历的对象。示例代码如下: 如果想要反向遍历,那么在遍历的时候就加上一个 。示例代码如下: 遍历字典的时候,需要使用 、`keys values DTL`中,执行一个方法不能使用圆括号的形式。遍历字典示例 阅读全文
posted @ 2019-01-20 23:41 random_lee 阅读(725) 评论(0) 推荐(0)
摘要:Title {# {% if age 您是未成年人,不能进入网吧#} {# {% elif age == 18 %}#} {# 您是满了18岁,可以进入网吧#} {# {% else %}#} {# 您已经是成年人了,要承担起家庭的责任了,也不能进入网吧#} {# {% endif %}#} ... 阅读全文
posted @ 2019-01-19 13:39 random_lee 阅读(670) 评论(0) 推荐(0)
摘要:1 from django.shortcuts import render 2 3 def index(request): 4 context={ 5 'books':[ 6 '5年高考3年模拟', 7 '家猪养殖与配种', 8 'Python 3 面向对象编程', 9 'MySQL数据库从删库到跑 阅读全文
posted @ 2019-01-19 13:39 random_lee 阅读(259) 评论(0) 推荐(0)
摘要:示例文件: template_variable_demo.zip 阅读全文
posted @ 2019-01-16 10:35 random_lee 阅读(635) 评论(0) 推荐(0)