本站首页    管理页面    写新日志    退出


«August 2025»
12
3456789
10111213141516
17181920212223
24252627282930
31


公告
 本博客在此声明所有文章均为转摘,只做资料收集使用。

我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:
日志总数:1304
评论数量:2242
留言数量:5
访问次数:7579064
建立时间:2006年5月29日




[Django]simpleJson的一个封装
软件技术

lhwork 发表于 2007/2/1 21:10:11

今天在调试 jElement.js (我用jQuery做的一个使用js生成Form的类)时,发现汉字返回有问题,是乱码,后来发现是simpleJson把utf-8编码的字符串直接转 成了unicode,但却是按字节来转的,不是真正的unicode。看来使用simpleJson时要小心,一定要转为unicode后再传给它。可是 这样很不方便,因此我写了一段小程序,可以自动判断要处理的数据,包括:普通字符串,Unicode字符串,List,Tuple(自动转为List), 字典,它可以根据情况来进行递归处理,直到将所有的字符串都转为Unicode。而且还将HttpResponse给封装进去了,这样可以直接在View 中返回了。代码为:from django.http import HttpResponse
from


阅读全文(2996) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]Relating a model to another model more than once
软件技术

lhwork 发表于 2007/2/1 14:48:10

In this example, a Person can have a mother and father -- both of which are other Person objects. Set


阅读全文(1609) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]related_name在django model中的应用
软件技术

lhwork 发表于 2007/2/1 14:46:03

今天在学习django0.95的时候遇到这样一个问题,我在一个model里面定义了两个foreignkey,都指向同一个model,结果在syncdb的时候老是报错,要我指定related_name,查到django.com上一篇文章Relating a model to another model more than once。 举例说明,我定义一个model名叫Tag, class TaggedItem(models.Model):
“”"A tag on an item.”"”
tag = models.SlugField()
content_type = models.ForeignKey(ContentType, related_name=’content’)
object_id = models.PositiveIntegerField()
cont

阅读全文(6456) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]django的外键查询
软件技术

lhwork 发表于 2007/2/1 14:44:09

假设我有两个表(model),分别叫useraccount和userrole: class UserAccount(meta.Model):
person  = meta.ForeignKey(Person, core=True)
account = meta.ForeignKey(User,   core=True) class UserRole(meta.Model):
account = meta.ForeignKey(UserAccount, core=True)
group   = meta.ForeignKey(Group, core=True)
active  = meta.BooleanField(_(’Active?’), default=True)
如果我知道useraccount中某个字段(field)的值,那么我就能取到相应的userrole: userroles.get_object(account__perso

阅读全文(4233) | 回复(0) | 编辑 | 精华 | 删除
 


[Django][Django学习]一步一步学习
软件技术

lhwork 发表于 2007/2/1 14:16:48

第一讲

对于 django 望而生畏的人,有兴趣看一看,程序如何从简单到复杂。

http://blog.donews.com/limodou/archive/2005/12/27/672689.aspx

在本文中我列举了一个最简单的hello,django的例子,有兴趣看一看,你可以先不知道django的model, admin,
  template,就是一个最简单的 hello, 看如何使用django做一个。

第二讲,生成一个web form 用来做加法的简单例子。

http://blog.donews.com/limodou/archive/2005/12/27/672944.aspx

阅读全文(3509) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]Django教程
软件技术

lhwork 发表于 2007/2/1 11:54:54

一、Hello Django!

1、生成项目目录
django-admin.py startproject newtedst这样就在当前目录下创建了一个newtest 目录,里面有四个文件:
__init__.py  表示这是一个 Python 的package
manage.py  提供简单化的 django-admin.py 命令,特别是可以自动进行DJANGO_SETTINGS_MODULES和 PYTHONPATH 的处理
settings.py  Django的配置文件
uls.py          url映射处理文件,Django 的url映射是url对于某个模块方法的映射,目前不能自动

阅读全文(6066) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]TextIndexingAbstractionLayer
软件技术

lhwork 发表于 2007/2/1 11:53:15

Introduction
Why do we need an abstraction layer for full-text indexing?
Developers often must implement search methods for their database, but unfortunately so far it has been easier to roll your own simple search than to deploy an existing project such as Lucene. Merquery provides an abstraction layer for popular text indexing engines and makes it easy for anyone to attach them to their database.

Using Merquery
You can enable Lucene indexing of a database table like so (assumi

阅读全文(1526) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]Merquery Summer of Code Results
软件技术

lhwork 发表于 2007/2/1 11:52:44

http://blog.case.edu/bmb12/2006/08/merquery_summer_of_code_results

This morning I commited a working version of Merquery to the Django Subversion repository.

svn co http://code.djangoproject....

My code in particular lives in branches/search-api/django/contrib/search.

The Lucene adapter

阅读全文(2030) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]More on Merquery
软件技术

lhwork 发表于 2007/2/1 11:50:24

http://blog.case.edu/bmb12/2006/03/more_on_merquery

A bunch of traffic has been directed to this blog due to the post about Merquery. Seems like there has been discussion going on in that posts's comments and also over at Jacob Kaplan-Moss' post.

As predicted, a lot of people are only seeing the "reinvention" aspect of Merquery. And admittedly, there is a lot that would need to be reinvented based on th

阅读全文(1760) | 回复(0) | 编辑 | 精华 | 删除
 


[Django]Custom SQL In Django
软件技术

lhwork 发表于 2007/2/1 11:49:14

For people wanting to write custom SQL queries for use in Django and are wondering how to make them "fit in" somehow with the rest of your code, a short tutorial follows. Requires a little bit of familiarity with Django to be useful, I suspect.

Also, if you are interested in learning more about some of the more advanced corners of Django, there are a few other people writing instructional pieces at the moment. In general, have a look at the Django aggregator for recent updates, but, in p

阅读全文(1875) | 回复(0) | 编辑 | 精华 | 删除
 


« 1 2 3 4 5 6 7 8 9 »



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.090 second(s), page refreshed 144771812 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号