第三篇最后写了,光知道那些基础的查询在项目中是没有什么卵用的,重点是实体关系映射(ORM),今天学习了,来记录一下,关键词:ForeignKey(多对一).OneToOneField(一对一).ManyToManyField(多对多) 实体定义: from django.db import models # Create your models here. class Publisher(models.Model): name = models.CharField(max_length=30)…
from:http://stackoverflow.com/questions/699468/python-html-sanitizer-scrubber-filter 通过下面这个代码就可以把内容过滤成干净的HTML内容,说明,这个代码来自上面Stackoverflow的回答 Use lxml.html.clean! It's VERY easy! from lxml.html.clean import clean_html print clean_html(html) <html> <…
数据库中的表示这样设计的 class C(models.Model): name = models.CharField(max_length=32) class B(models.Model): name = models.CharField(max_length=32) b = models.ForeignKey(C) class A(models.Model): name = models.CharField(max_length=32) a = models.ForeignKey(B) d…
1.安装python环境 1.1 安装python包管理器: wget https://bootstrap.pypa.io/get-pip.py sudo python get-pip.py 1.2 安装python虚拟环境virtualenv virtualenvwrapper 首先说明下为什么要装这两个包: First, it's important to understand that a virtual environment is a special tool used to ke…