Eg.
{{{
class SomeModel(models.Model):
name = models.CharField(max_length=10, default='example')
>>> from bug.models import SomeModel
>>> e1 = SomeModel(name='current')
>>> e1.save()
>>> e2 = SomeModel()
>>> e2.save()
>>> qs1 = SomeModel.objects.filter(name__startswith='ex').only('name')
>>> qs2 = SomeModel.objects.filter(name__startswith='cu').only('name')
>>> qs = qs1.union(qs2)
>>> print(qs.count())
>>> #raises ValueError : invalid literal for int() with base 10
}}}
If the first field contained in queryset is numeric then this error is not
raised.
Eg. remove .only() method above on both querysets and then .count() with
return correct result.
--
Ticket URL: <https://code.djangoproject.com/ticket/27990>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
I found the reason. union() does not support count().
--
Ticket URL: <https://code.djangoproject.com/ticket/27990#comment:1>
Comment (by Tim Graham):
I opened #27995 to raise a descriptive error on unsupported operations
following `QuerySet.union()`.
--
Ticket URL: <https://code.djangoproject.com/ticket/27990#comment:2>