I asked this question last week and haven't got an answer yet. Now I realize that it doesn't point to the real problem. So, I want to write a notification for a user and then render it to the template. My idea is to write all the html in the views.py file and then in the template just use the {html|safe} tag. I want the notifications to be like this:
user voted up your post on topic.
So, I tried to write the html as a string and use the %s to replace the usernames and the names of the topics, like this:
string_to_render = "<a href = '{% url ... %}'> %s </a> voted up your <a href = '{% url ... %}'> post </a> on the <a href = '{% url ... %}'> %s </a>" %(user, topic)
The %s is there to replace the user and the topic names. But python also understands django's "% url" as an unsigned decimal replacement and I get the error:
%u format: a number is required, not unicode
So, if there isn't an easy solution to this problem. I am open to suggestions about how to render notifications. Maybe I shouldn't write the whole notification before rendering it and I should try writing them on html and use many content variables? That would also require many {% if-else %} template tags cause vote-up is only one of the notifications I would like to give to the user. That is just an idea, but surely there is a better way to do it.
Thanks in advance for your help.