def get_block_type_queryset(self,db):
qry = None
for m in self.get_block_models():
try:
admin_url(m, 'add')
except NoReverseMatch:
continue
q = models.Q(app_label=m._meta.app_label) & \
models.Q(model=m._meta.object_name.lower())
qry = qry | q if qry else q
# If qry has not been set, i.e. no blocks extend the block_type, or
# Blocks do not have an admin, then exclude all content types..
return ContentType.objects.filter(qry).using(db) if qry else \
ContentType.objects.exclude(pk__gte=0)
评论列表
文章目录