First of all, thanks about this amazing lib! I've found a little issue where values() doesn't work after calling order_by().
Code to replicate the problem:
class Question(models.Model):
name = models.CharField(max_length=350)
class Answer(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
class Answer2(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
query = QuerySetSequence(Answer.objects.all(), Answer2.objects.all())
query.values('question__name') # This works
query.order_by('question__name').values('question__name') # This does NOT work
The error thrown is the following:
File "/my_path/venv/lib/python3.10/site-packages/queryset_sequence/init.py", line 565, in iter
self._fetch_all()
File "/my_path/venv/lib/python3.10/site-packages/queryset_sequence/init.py", line 542, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/my_path/venv/lib/python3.10/site-packages/queryset_sequence/init.py", line 367, in iter
yield from super().iter()
File "/my_path/venv/lib/python3.10/site-packages/queryset_sequence/init.py", line 210, in _ordered_iterator
iterables = sorted(iterables, key=comparator)
File "/my_path/venv/lib/python3.10/site-packages/queryset_sequence/init.py", line 194, in comparator
return _comparator(tuple_1[2], tuple_2[2])
File "/my_path/venv/lib/python3.10/site-packages/queryset_sequence/init.py", line 143, in comparator
v1 = cls._get_fields(i1, *field_names)
File "/my_path/venv/lib/python3.10/site-packages/queryset_sequence/init.py", line 379, in _get_fields
return itemgetter(*field_names)(obj)
KeyError: 'question.name'
First of all, thanks about this amazing lib! I've found a little issue where
values()doesn't work after callingorder_by().Code to replicate the problem:
The error thrown is the following: