Impact factor for posts is a measurement of importance.

Impact factor for users reflect their authority, reputation and contribution on a particular topic.

Rating reflects the quality of posts.

Rating on Voofie is not a simple average of all ratings, but a weighted average of rating, weighted by the impact factor of users who rated.

Explore exciting communities of

CKEditor Widget for Django form

16 Jul 10

This is an example snipplet on integrating CKEditor into Django

Bookmark and Share

Integrating CKEditor into django is easy! Just copy the following code into your forms.py then you get a CKeditorWidget that you can easily use in forms.

class CKeditorWidget(forms.Textarea):
attrs={}

def __init__(self, toolbar,height=250):
self.toolbar=toolbar
self.height=height
class Media:
js=('/site_media/ckeditor/ckeditor.js',)

def render(self, name, value, attrs=None):
if value is None:
value = ''
value = force_unicode(value) #important when pre-fill content contains unicode
rendered = super(CKeditorWidget,self).render(name, value, attrs)
return mark_safe(self.media)+ rendered+mark_safe(
u"""<script type="text/javascript">
$(function(){
CKEDITOR.replace('%s', {toolbar:'%s', height:'%s',
on:{instanceReady:function(ev){ #execute when CKEditor initiate, useful for setup codes
this.dataProcessor.writer.indentationChars='';
}}
});
});
</script>
"""%(name, self.toolbar,self.height))

Following example show how to use the CKeditorWidget, the toolbar value is the toolbar setting you want to use.

ckeditorfield=forms.CharField(label='CKEditor', widget=CKeditorWidget(toolbar='Simple',height=300))
0 Comments

Please login to post comment.

What is Voofie?

Voofie organizes knowledge, discovers useful resources and recognizes knowledgable users.

Bookmark your blog in Voofie to get more traffic as well as building a reputation in your field!

Explore more about it. Become a member—our FREE Registration takes just seconds.

Page Info
14Impacts
0/0 rates
1268
Your Rating:
Version: 1
Submitted: 16 Jul 10
Permalink