django-sortedm2m
django-sortedm2m copied to clipboard
Duplicated query in forms.py
I have noticed a duplicated query while debugging openwisp2 generated by django-sortedm2m.
It seems that this line: https://github.com/gregmuellegger/django-sortedm2m/blob/bcb24c829576e14c416066b8018fc8a2dee58b7b/sortedm2m/forms.py#L52 Is evaluating the same queryset twice, hence querying 2 times the database for the same information.
The first query is generated when chain()
is called, then when enumerate()
is called.
The current code is surely elegant and compact, but duplicated queries aren't equally nice.
I currently have no idea how to fix this. Any suggestion that may help me to send a patch?