随笔分类 -  Django

摘要:1.安装依赖包1.1 ubuntu安装apt-get install python-devapt-get install libjpeg-devapt-get install libjpeg8-devapt-get install libpng3 apt-get install libfreetyp... 阅读全文
posted @ 2014-10-08 23:57 Mingxx 阅读(1952) 评论(0) 推荐(0)
摘要:今天安装PIL花了我好多的时间。刚开始,我手动下载PIL原码,编译安装。启动我的django项目,报下面的错误,完全不懂是么意思。CommandError: One or more models did not validate:user.userprofile: "photo": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .手动测试了一下:The _imaging extensio 阅读全文
posted @ 2014-04-04 23:22 Mingxx 阅读(1064) 评论(0) 推荐(0)
摘要:django对于事务的支持分几个层次。1. 什么都不管的话,它是使用 autocommit 方式。也就是在执行了 save() 或 delete() 之后就自动提交了。2. 通过增加 Transaction 中间件来实现自动的事务支持。我感觉这个是非常方便的做法。使用它,你首先需要在 settings.py 中增加一个中间件的设置:MIDDLEWARE_CLASSES = ("django.middleware.common.CommonMiddleware","django.middleware.sessions.SessionMiddleware", 阅读全文
posted @ 2012-12-18 13:50 Mingxx 阅读(630) 评论(0) 推荐(0)
摘要:在ModelForm中添加新的属性class AuthorForm(ModelForm): class Meta: model = Author widgets = { 'name': TextInput(attrs={'placeholder': 'name'}), }在Form的成员中添加属性q = forms.CharField(label='search', widget=forms.TextInput(attrs={'placeholder': 'Search'})) 阅读全文
posted @ 2012-11-07 00:00 Mingxx 阅读(632) 评论(0) 推荐(0)