我有这段代码,我想优化:
articles = Articles.objects.filter(active=True).all().order_by('-added')[start_from:per_page+start_from]
tags = dict()
for article in articles:
tags[article.id] = Tags.objects.filter(articles=article).all()
我认为该代码可以,但它们返回错误:
articles = Articles.objects.filter(active=True).all()[start_from:per_page+start_from]
articles_tags = Tags.objects.filter(articles__in=articles).all()
tags = dict()
for article in articles:
tags[article.id] = articles_tags.filter(articles=article).all()
错误信息
(1235, "This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'")