On Mon, 2008-03-31 at 06:50 -0500, James Bennett wrote:
> On Mon, Mar 31, 2008 at 6:46 AM, James Bennett <[EMAIL PROTECTED]> wrote:
> >  Since subclassing Field to create your own custom model fields is easy
> >  and documented, why not write an "HTMLField" class which calls
> >  mark_safe() before returning a value?
> 
> And though I may be wrong, I think it'd be as simple as:
> 
> from django.db.models import TextField
> from django.utils.safestring import mark_safe
> 
> class HTMLField(TextField):
>     def to_python(self, value):
>         return mark_safe(value)

That will mostly work. But when you initially assign to the attribute it
isn't passed through to_python(), so you have to decide whether that's
a situation that is of concern or not.

Malcolm

-- 
The sooner you fall behind, the more time you'll have to catch up. 
http://www.pointy-stick.com/blog/


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

Reply via email to