What about an HtmlField

72 views
Skip to first unread message

ska...@gmail.com

unread,
Jul 25, 2005, 11:27:32 PM7/25/05
to django-d...@googlegroups.com
During the course of using django I found that I wanted not just a
TextField but and HtmlField. So I made some quick changes to integrate
tinymce ( http://tinymce.moxiecode.com/ ) into Django.

You can see a screenshot at
http://jay.skabber.com/images/tinymce_django.png

Is this something that could be integrated into Django?

I figured this could be done either:
1. meta.TextField('description',html=true)
2. meta.HtmlField('description',theme='simple')
3. could this not be integrated into Django but done as part of a
template?

Adrian Holovaty

unread,
Jul 26, 2005, 11:25:52 AM7/26/05
to django-d...@googlegroups.com
On 7/25/05, ska...@gmail.com <ska...@gmail.com> wrote:
> During the course of using django I found that I wanted not just a
> TextField but and HtmlField. So I made some quick changes to integrate
> tinymce ( http://tinymce.moxiecode.com/ ) into Django.
>
> You can see a screenshot at
> http://jay.skabber.com/images/tinymce_django.png
>
> Is this something that could be integrated into Django?

Very cool!

Yes, it'd be possible to integrate that into Django. Does tinymce's
license allow such integration? We're BSD, and they're LGPL. We'd have
to figure this out before going further.

Adrian

Jacob Kaplan-Moss

unread,
Jul 26, 2005, 12:02:54 PM7/26/05
to django-d...@googlegroups.com
On Jul 26, 2005, at 10:25 AM, Adrian Holovaty wrote:
> Yes, it'd be possible to integrate that into Django. Does tinymce's
> license allow such integration? We're BSD, and they're LGPL. We'd have
> to figure this out before going further.

I think a better way to handle this would be to add an option to
fields -- either all fields or just text fields -- to allow
specifying a class. That was you could use any rich-text field that
uses proper unobtrusive javascript techniques with a simple
combination of class and "js" admin options::

class SomethingCool(meta.Model):
fields = (
meta.TextField("content", css_class="tinymce"),
)
admin = (
js = ("/js/tinymcs.js",)
)

Eh?

Jacob

Simon Willison

unread,
Jul 26, 2005, 12:26:47 PM7/26/05
to django-d...@googlegroups.com
> I think a better way to handle this would be to add an option to
> fields -- either all fields or just text fields -- to allow
> specifying a class. That was you could use any rich-text field that
> uses proper unobtrusive javascript techniques with a simple
> combination of class and "js" admin options::
>
> class SomethingCool(meta.Model):
> fields = (
> meta.TextField("content", css_class="tinymce"),
> )
> admin = (
> js = ("/js/tinymcs.js",)
> )
>
> Eh?

I like that idea a lot. It would be neat to have a tutorial explaining this.

ska...@gmail.com

unread,
Jul 26, 2005, 4:16:23 PM7/26/05
to django-d...@googlegroups.com
I think Jacob is right, it would be nice for people to use whatever
wysiwyg editor they like. I will work on making my tinymce example
more generic and probably post something tonight.

ska...@gmail.com

unread,
Jul 26, 2005, 8:30:01 PM7/26/05
to django-d...@googlegroups.com
> I like that idea a lot. It would be neat to have a tutorial explaining this.

Yes it would <a
href="http://www.socialistsoftware.com/?p=8">http://www.socialistsoftware.com/?p=8</a>

Adrian Holovaty

unread,
Jul 26, 2005, 8:40:25 PM7/26/05
to django-d...@googlegroups.com
On 7/26/05, Jacob Kaplan-Moss <ja...@jacobian.org> wrote:
> I think a better way to handle this would be to add an option to
> fields -- either all fields or just text fields -- to allow
> specifying a class. That was you could use any rich-text field that
> uses proper unobtrusive javascript techniques with a simple
> combination of class and "js" admin options::
>
> class SomethingCool(meta.Model):
> fields = (
> meta.TextField("content", css_class="tinymce"),
> )
> admin = (
> js = ("/js/tinymcs.js",)
> )

Note that you wouldn't necessarily have to add a "css_class"
attribute. Each field in the Django admin gets an HTML ID attribute,
and each type of field gets an HTML class representing that type. With
those preexisting hooks, a script pointed-to by admin.js could find
all the TextFields and add the WYSIWYG stuff to them unobtrusively.

Adrian
Reply all
Reply to author
Forward
0 new messages