I'm trying to call a function from my model (check_nick) in my template. It appears that the template is successfully hitting the function since the items in the function are printed. However I'm not getting the expected result (True) as the user.group I'm testing with is NICK which is part of the NICK_BRANDS list.
MODEL.PY:
NICK_BRANDS = ['NICK', 'NICKT', 'NICKN', 'NICKK', 'NICKA']
class User():
group = models.ForeignKey(Brand, null=True, blank=True)
def check_nick(self):
brand = self.group
print brand //prints NICK
print brand in NICK_BRANDS //prints False (should be True!)
if brand in NICK_BRANDS:
return True
else:
return False
TEMPLATE:
{% if user.check_nick %}
//add some markup
{% endif %}