I have a custom filter parses a CharField for usernames marked with '@', and replaces them with a hyperlink to their profile page:-
def hyperlink_usernames(note): for word in note.split(): if '@' in word: try: User.objects.get(username=word.strip('@')) note = note.replace(word, mark_safe('<a href="/%s">%s</ a>' % \ (word.strip('@'), word))) except: pass return note I'm trying to mark_safe only the hyperlinks so that they are not autoescaped, but mark_safe only seems to work if I apply it to the returned string as a whole, which would be unsafe. Is this at all possible?
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.