Answer the question
In order to leave comments, you need to log in
Why does Django tag output +0 for the base template?
I have a new comment count in radish, created a simple_tag that outputs the number of new comments to the base.html header:
@register.simple_tag()
def get_new_comm(id):
cacheDB = redis.StrictRedis()
temp = cacheDB.get("comments:%s" % id)
if temp:
return '<font color="red" >+' + temp + '</font>'
else:
return ""
if temp!= 0 :
import redis
cacheDB = redis.StrictRedis()
Answer the question
In order to leave comments, you need to log in
Do this, convert the value to an integertemp = int(cacheDB.get("comments:%s" % id))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question