I am trying to add templatetags in using django, but i get this error after creating the template tags, i don’t know if there is something i need to change in my settings.py to make this work.
template.html
{% extends 'base/base.html' %}
{% load static %}
{% load course_custom_tags %}
{% block content %}
course_custom_tags.py
from course.models import UserCourse , Course
register = template.Library()
@register.simple_tag
def is_enrolled(request , course):
user = None
if not request.user.is_authenticated:
return False
# i you are enrooled in this course you can watch every video
user = request.user
try:
user_course = UserCourse.objects.get(user = user , course = course)
return True
except:
return False