diff --git a/core/templatetags/has_plan.py b/core/templatetags/has_plan.py index 411327c..94a568f 100644 --- a/core/templatetags/has_plan.py +++ b/core/templatetags/has_plan.py @@ -1,8 +1,11 @@ from django import template -from core.models import User + register = template.Library() + @register.filter def has_plan(user, plan_name): + if not hasattr(user, "plans"): + return False plan_list = [plan.name for plan in user.plans.all()] - return plan_name in plan_list \ No newline at end of file + return plan_name in plan_list