1👍
You can get the model of the queryset and then filter Point
for that particular content type:
@register.simple_tag()
def get_points_for_query(q):
ct = ContentType.objects.get_for_model(q.model)
return Point.objects.filter(content_type=ct, object_id__in=q) \
.prefetch_related('content_obj').order_by('pk')
I’m not sure in the object_id__in=q
clause. If it will not work then try:
object_id__in=q.values_list('id', flat=True)
This should work fine.
Source:stackexchange.com