Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render(self, context):
try:
item = int(self.item.resolve(context))
user = context['user']
liked = pin_likes.objects.filter(user=user, post=item).count()
if liked:
return 'btn-danger'
else:
return ''
except template.VariableDoesNotExist:
return ''