5.拷贝FCKEditor目录下的 fckeditor.py 到 util目录下.查找 IsCompatible 方法定义.修改如下
def IsCompatible(self):
if self.sAgent:
sAgent = self.sAgent
elif (os.environ.has_key("HTTP_USER_AGENT")):
sAgent = os.environ.get("HTTP_USER_AGENT", "")
else:
sAgent = ""
if (sAgent.find("MSIE") >= 0) and (sAgent.find("mac") < 0) and (sAgent.find("Opera") < 0):
i = sAgent.find("MSIE")
iVersion = float(sAgent[i+5:i+5+3])
if (iVersion >= 5.5):
return True
return False
elif (sAgent.find("Gecko/") >= 0):
i = sAgent.find("Gecko/")
iVersion = int(sAgent[i+6:i+6+8])
if (iVersion >= 20030210):
return True
return False
elif (sAgent.find("Opera/") >= 0):
i = sAgent.find("Opera/")
iVersion = float(sAgent[i+6:i+6+4])
if (iVersion >= 9.5):
return True
return False
elif (sAgent.find("AppleWebKit/") >= 0):
p = re.compile('AppleWebKit\/(\d+)', re.IGNORECASE)
m = p.search(sAgent)
if (m.group(1) >= 522):
return True
return False
else:
return False
|
6.修改 settings.py 修改 MIDDLEWARE_CLASSES 增加 util.cachemiddleware.CacheMiddleware
7.在项目下建立static目录.把Fckeditor拷贝到static目录下,重命名为 fck . 修改 urls.py.增加
fck目录的映射
(r'^tpl/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_DIR}), <
/td> |
8.使用举例
from util.editor import FCKEditor
class UserProfileForm(ModelForm):
info = forms.CharField(widget=FCKEditor({'basepath':'/tpl/fck/','toolbar':'Basic','width':'80%','height':'200'}))
|
阅读(2865) | 评论(1) | 转发(0) |