tags:

views:

35

answers:

1

I have a notifications app that generates notifications for users. The notification class has to be really general, because notifications are generated by all sorts of different things.

My question is this: How do I insert links into the text of the notifications?

What I tried was this:

note = Notification(..., notification="""%s %s has accepted the task: <a href="/tasks/%d/">%s</a>.""" % (request.user.first_name, request.user.last_name, task.id, task.name), ...)

In retrospect, it's obvious this wouldn't work. How should I go about this? Thanks in advance!

Edit: Django is outputting the < and > characters as lt and gt

+2  A: 

What you've got will work fine, provided that when you output the Notification, Django doesn't escape it, either using the safe filter in your template, or mark_safe somewhere in your view or model code.

Dominic Rodger
Perfect. I didn't know about the safe filter.
Dane Larsen