django基础篇
python的WEB框架有Django、Tornado、Flask 等多种,Django相较与其他WEB框架其优势为:大而全,框架本身集成了ORM、模型绑定、模板引擎、缓存、Session等诸多功能。 一、基本的配置 1、创建django程序 终端命令:django-admin startproject sitename IDE创建Django程序时,本质上都是自动执行上述命令 其他常用命令:...
View ArticlePyCharm断点调试django
我在用PyCharm开发django程序的时候,对于打印日志调试程序的方式感觉还是有点麻烦和不直观,所以研究了一下断点调试的方法如下: 1、打开你的工程,在菜单栏里找到Run-->Edit Configurations 2、在打开的对话框里边选择python,点击+号 4、选择Python 5、出现了一个新的项Unnamed,你可以把它改名叫debug,好听一点...
View ArticleHow we used generic relations to add comments to model instances
As I talked to some people, few new about Django’s Generic Relation and Generic Foreign Key. And when I was studying it to apply on our system, I realised that the documentation can be kind of tricky...
View Article【我拼搏的2016】python 学习之路
2016年是一个丰收的一年,这一年我选择了51学院python 微职位培训课程。学习的初衷是为了提升自己技术,增强职场竞争力。现在竞争的年代,不断进步才是生存之道。说实话在漫长的职业生涯中,由其是做IT技术这个方向,提升自己是时时刻刻要做的事。所以选择了这个学习机会 ,就是给自己一个提升的好机会...
View Article建造者模式 ―― Python 描述
建造者模式(生成器模式、Buidler Pattern)和抽象工厂模式的目的都是用来创建复杂的对象,但是创建的过程是截然不同的。 在抽象工厂模式中,抽象出了创建方法,使用者只能按照预定好的步骤新创建一个对象。 在建造者模式中,使用者可以按照自己的想法,在合理的范围内定制自己所需要的对象。 所以当有一下情况时候,需要考虑使用建造者模式: 对象的创建步骤可以独立于创建过程的时候...
View ArticleLooking Forward
Published 12/16/2016 We have justreleased Krita 3.1, but we are already deep into coding again! We will continue releasing bug fix versions of Krita 3.1.x until it’s time to release 3.2 (or maybe...
View ArticleImport Python: ImportPython Issue 103 - Pycon canada videos, debugging,...
PyCon Canada Videos PyCon Canada's Youtube channel now has most of the event's videos. video , conference , pycon-canada devRant the Dev Community Join our community of 15k+ developers &...
View ArticleExperimental MySQL UDF code partially written in Python
Hi dear all, I would like to share our experimental tests about, writing UDF with python. So the basic idea was writing a UDF for factorial calculation. The interesting part was to move factorial...
View ArticleA Practical Use For Python Decorators ― Logging, Error Checks, and Timing
When using a python decorator, especially one defined in another library, they seem somewhat magical.Take for example Flask’s routing mechanism. If I put some statement like @app.route("/") above my...
View Article探究如何给Python程序做hotfix
使用python来写服务器端程序,很大的一个优势就是可以进行热更新,即在不停机的情况下,使改动后的程序生效。在开发阶段,这个功能可以大大提高开发效率(写代码 启动服务器 看效果 改代码 hotfix 看效果 提交~);而在生产环境中,可以以最小的代价(不停机)修复线上的bug。...
View ArticleThe third (and final) Python bindings for LLVM
Goal The main goal of llvmcpy is to provide python bindings for the LLVM project that are fast and require the lowest possible maintainance effort. To achive this, we use CFFI to parse the (slightly...
View ArticleDjango Administration: Inlines for Inlines
The default Django model administration comes with a concept of inlines . If you have a one-to-many relationship, you can edit the parent and its children in the same form. However, you are limited in...
View Article零基础学Python到找工作-资源汇总
零基础学python到找工作-资源汇总 一点号越来夜来香昨天 今天整理了一些从开始学Python到找工作,整个端到端的流程中需要的一些资源和资料,可以对学Python有一个全局的了解.对里面的内容我补充了一些自己的看法和经验,分享给大家~~ 1大神入门指导:廖雪峰的官方网站...
View ArticleDjango Rest framework使用问题及解决方法
更新记录 2016-01-29 初稿 问题1 ViewSet 没有写 serializer_class 属性,而是重写了 get_serializer_class() 方法,出现 Cannot use OrderingFilter on a view which does not have either a 'serializer_class' or 'ordering_fields'...
View Articledjango rest framework入门笔记及跳坑记录
更新记录 2016-01-26 初稿 序列化时嵌套显示外键关联字段 自动 使用 depth 参数指定外键深度 手动指定 使用外键对应 model 的小写为属性,外键对应的 model 序列化程序为值 以下例子在 HospitalPic 序列化结果里嵌套显示 Hospital models.py from django.db import models class...
View Articledjango进阶
一、model 到目前为止,当我们的程序涉及到数据库相关操作时,我们一般都会这么搞: 创建数据库,设计表结构和字段 使用 mysqldb 来连接数据库,并编写数据访问层代码 业务逻辑层去调用数据访问层执行数据库操作 import MySQLdb def GetList(sql): db = MySQLdb.connect(user='root', db='wupeiqidb',...
View ArticlePython的object和type理解
1、节选自python Documentation 3.5.2的部分解释 Objects are Python’s abstraction for data. All data in a Python program is represented by objects or by relations between objects. (In a sense, and in conformance...
View ArticlePython Insider: Python 3.6.0 release candidate 2 is now available
python 3.6.0rc2 is the second release candidate for Python 3.6, the next major release of Python. Codefor 3.6.0 is now frozen. Code for 3.6.0 is now frozen. 3.6.0rc2 is the same code base as the first...
View ArticleDjango Rest framework里的API请求频率控制
更新记录 2016-08-25 初稿 Django Rest framework 有自带的频率控制配置 全局设置 REST_FRAMEWORK = { 'DEFAULT_THROTTLE_CLASSES': ( # 开启匿名用户接口请求频率限制 'rest_framework.throttling.AnonRateThrottle', # 开启授权用户接口请求频率限制...
View Article发文后自动分享到微博和Twitter-Python
我在每次发帖后都会把帖子手动分享到微博、Twitter等社交网络,但是很多时候我会忘,于是我就想自动化这个过程。 本站使用的是WordPress博客系统,不知道有没有现成的插件。我使用python做,原因是我有切换到Django的打算,使用Python做可以方便以后集成。还有就是,我对php不熟。 基本步骤: 通过RSS订阅获得最新文章 调用微博/推特api发微博/推 代码:...
View Article