{{{#!python
class Temp(models.Model):
pass
class TempUuid(models.Model):
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
temp = models.ForeignKey(Temp)
}}}
The result of the following code:
{{{#!python
>>> temp = Temp.objects.create()
>>> TempUuid.objects.create(temp=temp)
>>> TempUuid.objects.prefetch_related('temp').values_list('uuid',
flat=True)
}}}
is:
{{{#!python
TypeError: UUID objects are immutable
}}}
Note that there's no exception when removing the `flat=True`.
--
Ticket URL: <https://code.djangoproject.com/ticket/26264>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0
Comment:
Without `flat=True`, there's no exception, and the `prefetch_related()`
call apparently has no effect. In similar cases, where optimizations no
longer made sense, we simply dropped them, so this behavior seems right;
in that case, that should also be the behavior with `flat=True`.
--
Ticket URL: <https://code.djangoproject.com/ticket/26264#comment:1>
Comment (by timgraham):
Attached is a regression test for Django's test suite.
--
Ticket URL: <https://code.djangoproject.com/ticket/26264#comment:2>
* Attachment "26264-test.diff" added.
--
Ticket URL: <https://code.djangoproject.com/ticket/26264#comment:3>
* status: new => assigned
* owner: nobody => Uran198
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/6204 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/26264#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"5e2c4d7afbaeec196aedb9888a47e0b635ff55d4" 5e2c4d7a]:
{{{
#!CommitTicketReference repository=""
revision="5e2c4d7afbaeec196aedb9888a47e0b635ff55d4"
Fixed #26264 -- Fixed prefetch_related() crashes with
values_list(flat=True)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26264#comment:5>