Enable users to input formatted text

189 views
Skip to first unread message

Continuation

unread,
Dec 21, 2009, 2:12:06 AM12/21/09
to Django users
I have a TextField() field that stores user entered text. However the
formatting is a bit weird, eg. new lines are lost when displaying that
field.

What is the best way to retain that formatting and also enable users
to format their inputs with either HTML tags or some rich text editors?

BobAalsma

unread,
Dec 21, 2009, 5:09:25 AM12/21/09
to Django users
Umm, I think you would then also invite/enable hackers to upload
unwanted thingies, such as viruses and scripts...

pjrh...@gmail.com

unread,
Dec 21, 2009, 5:50:03 PM12/21/09
to Django users
You've got to decide what you want to allow. If the users are trusted
you could allow them to input HTML, then you have to make sure its
marked as safe so the HTML is not escaped.[1]

Alternatively you could use a markup language that can be converted to
HTML.[2]

If you just want the newlines, you can convert them to HTML.[3]

Finally, theres a variety of different options for rich text editors,
for example django-tinymce[4]

1. http://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe
2. http://docs.djangoproject.com/en/dev/ref/contrib/#ref-contrib-markup
3. http://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks
4. http://code.google.com/p/django-tinymce/

Continuation

unread,
Dec 21, 2009, 6:22:43 PM12/21/09
to Django users
django-tinymce looks like is what I need.

Thanks for pointing me to that.

Gabriel Farrell

unread,
Dec 23, 2009, 12:22:33 AM12/23/09
to django...@googlegroups.com
If you have any trouble with tinymce look at Markdown in
django.contrib.markup, especially with the "safe" extension. Nice
lightweight solution.

> --
>
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>
>

Reply all
Reply to author
Forward
0 new messages