django-parler

Translatable Manytomany fields in admin generate many queries

≡放荡痞女 提交于 2019-12-06 04:46:23
问题 I am using django-parler (a derivative of django-hvad) for translations. In admin when displaying Foreignkey fields with manytomany relationship, django runs a single query for each: So when there are 300 services there would be as many queries. I think the prefetch_related on get_queryset doesn't apply to mantomany filters/lists, correct me if I am wrong: def get_queryset(self, request): return super(DoctorAdmin, self).get_queryset(request).prefetch_related('translations', 'services_

Translatable Manytomany fields in admin generate many queries

怎甘沉沦 提交于 2019-12-04 09:55:01
I am using django-parler (a derivative of django-hvad) for translations. In admin when displaying Foreignkey fields with manytomany relationship, django runs a single query for each: So when there are 300 services there would be as many queries. I think the prefetch_related on get_queryset doesn't apply to mantomany filters/lists, correct me if I am wrong: def get_queryset(self, request): return super(DoctorAdmin, self).get_queryset(request).prefetch_related('translations', 'services__translations') has no effect on number of queries. Enabling caching on parler (as the author suggested here )