|
|
@@ -6,6 +6,7 @@ from typing import Dict, Any
|
|
|
import yaml
|
|
|
from django import template
|
|
|
from django.conf import settings
|
|
|
+from django.contrib.contenttypes.models import ContentType
|
|
|
from django.template.defaultfilters import date
|
|
|
from django.urls import NoReverseMatch, reverse
|
|
|
from django.utils import timezone
|
|
|
@@ -78,6 +79,25 @@ def meta(obj, attr):
|
|
|
return getattr(obj._meta, attr, '')
|
|
|
|
|
|
|
|
|
+@register.filter()
|
|
|
+def content_type(obj):
|
|
|
+ """
|
|
|
+ Return the ContentType for the given object.
|
|
|
+ """
|
|
|
+ return ContentType.objects.get_for_model(obj)
|
|
|
+
|
|
|
+
|
|
|
+@register.filter()
|
|
|
+def content_type_id(obj):
|
|
|
+ """
|
|
|
+ Return the ContentType ID for the given object.
|
|
|
+ """
|
|
|
+ content_type = ContentType.objects.get_for_model(obj)
|
|
|
+ if content_type:
|
|
|
+ return content_type.pk
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
@register.filter()
|
|
|
def viewname(model, action):
|
|
|
"""
|