0

I would like to add some very basic rich text editing in my charfields, only bold, italic and a custom fontsize selector (small-normal-large -- relative to another model field setting). At first I tried to use django-tinymce, but when using a formset I had some problems that the media files for tinymce only applied to the first form in the set, and my added js function doesnt work. Maybe I need a custom widget for this small-normal-large fontsize selector anyway (or do this as a model field).

Is it recommendable to user TinyMCE and try to customize it in this case (if so, how), or is there a more straightforward way to go using the form I've already created?

Here's what I have in my form (dynamically changing the textarea size, and calling js function in the template to limit chars):

text=forms.CharField(max_length = 1000, widget=forms.widgets.Textarea()) 
def __init__(self, *args, **kwargs):
     size = kwargs.pop('size')
     maxChars = kwargs.pop('maxChars')
     super(MyForm, self).__init__(*args, **kwargs)
     self.fields['text'].widget.attrs['onkeypress'] = 'return textCounter(this, this.form.counter, %d);' % maxChars
     self.fields['text'].widget.attrs['rows'] = size
     self.fields['text'].widget.attrs['cols'] = '40'
HdN8
  • 2,953
  • 3
  • 24
  • 26

1 Answers1

0

You can use ckeditor, which you can enable without any django-app. An other alternative is the (very) basic glow editor, see BBC's glow homepage.

Personnally I would not include that javascript in your form btw, but include it in the template.

Izz ad-Din Ruhulessin
  • 5,955
  • 7
  • 28
  • 28
  • Ok, went with ckeditor, this seems to be doing the trick, nice one. Suppose in this case since I will be defining the textareas in the template as opposed to thru the form widget, I will take your advice on moving the javascript all into the template. Im a novice, so still getting used to how to play with the template tags. Thanks for the advice! – HdN8 Nov 29 '10 at 20:09
  • For more information about forms and their media, this might be of use to you: http://docs.djangoproject.com/en/dev/topics/forms/media/ – Izz ad-Din Ruhulessin Nov 30 '10 at 15:49