代码改变世界

django 导出 EXCEL

2019-09-29 09:52 by 其修远兮666, 330 阅读, 0 推荐, 收藏,
摘要:import MySQLdb import xlwt import StringIO from django.shortcuts import HttpResponse from MySQLdb.cursors import DictCursor conn = MySQLdb.connect(hos 阅读全文

Django SETTING 配置

2019-09-18 11:45 by 其修远兮666, 236 阅读, 0 推荐, 收藏,
摘要:import os# Build paths inside the project like this: os.path.join(BASE_DIR, ...)BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 阅读全文

pickle_json 序列化反序列化

2019-01-27 22:05 by 其修远兮666, 142 阅读, 0 推荐, 收藏,
摘要:JSON 通用,只能识别 列表,字典等简单数据 PICKLE仅PYTHON适用,可序列化复杂类似对象等 使用举例: import json,pickleclass Account: def __init__(self,total,pay): self.total = total self.pay = 阅读全文

python 时间处理

2019-01-24 16:08 by 其修远兮666, 120 阅读, 0 推荐, 收藏,
摘要:#_*_coding:utf-8_*_ __author__ = 'Alex Li' import time # print(time.clock()) #返回处理器时间,3.3开始已废弃 , 改成了time.process_time()测量处理器运算时间,不包括sleep时间,不稳定,mac上测不 阅读全文

自制分页模版

2018-07-10 02:02 by 其修远兮666, 249 阅读, 0 推荐, 收藏,
摘要:class PagerHelper: def __init__(self,total_count,current_page,base_url,per_page=5): #默认条数5 self.total_count = total_count #封装到对象里 self.current_page = 阅读全文

django 附件添加到数据库

2018-06-13 18:03 by 其修远兮666, 664 阅读, 0 推荐, 收藏,
摘要:1.使用ImageField首先要安装Pillow pip install pillow 2.建立数据库 1 class Test(models.Model):2 name = models.CharField(max_length=50)3 image = models.ImageField(up 阅读全文

kindeditor

2018-06-09 13:06 by 其修远兮666, 93 阅读, 0 推荐, 收藏,
摘要:<html> <head> <link rel="stylesheet" href="kindeditor/themes/default/default.css" /> <script charset="utf-8" src="kindeditor/kindeditor-min.js"></scri 阅读全文

Django 时间与时区问题

2018-06-09 13:04 by 其修远兮666, 214 阅读, 0 推荐, 收藏,
摘要:在Django的配置文件settings.py中,有两个配置参数是跟时间与时区有关的,分别是TIME_ZONE和USE_TZ 如果USE_TZ设置为True时,Django会使用系统默认设置的时区,即America/Chicago,此时的TIME_ZONE不管有没有设置都不起作用。 如果USE_TZ 阅读全文