#26819: Using a ArrayField on Meta.unique_together throws "unhashable type:
'list'"
on validate_unique method
------------------------------+-------------------------------------
Reporter: Gleber Diniz | Owner: PREMANAND
Type: Bug | Status: assigned
Component: Forms | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+-------------------------------------
Changes (by Tim Graham):
* component: contrib.admin => Forms
Old description:
> It happens on a second save (when there is already data to be validated)
>
> On this line: "if row_data in seen_data:", because row_data contains a
> list and seen_data is a set (row_data: (1, [1, 1]) / seen_data: set())
>
> Example to reproduce:
>
> models:
> {{{#!python
> class Map(models.Model):
> name = models.CharField(_('name'), max_length=128)
>
> class MapSpot(models.Model):
> map = models.ForeignKey('body.Map', related_name='spots')
> position = ArrayField(models.IntegerField(), size=2)
>
> class Meta:
> unique_together = [('map', 'position')]
> }}}
>
> admin:
> {{{#!python
> class MapSpotInline(admin.TabularInline):
> model = MapSpot
> extra = 0
>
> @admin.register(Map)
> class MapAdmin(admin.ModelAdmin):
> inlines = [MapSpotInline]
> }}}
New description:
It happens on a second save (when there is already data to be validated)
On this line: "if row_data in seen_data:", because row_data contains a
list and seen_data is a set (row_data: (1, [1, 1]) / seen_data: set())
Example to reproduce:
models:
{{{#!python
class Map(models.Model):
name = models.CharField('name', max_length=128)
class MapSpot(models.Model):
map = models.ForeignKey('body.Map', related_name='spots')
position = ArrayField(models.IntegerField(), size=2)
class Meta:
unique_together = [('map', 'position')]
}}}
admin:
{{{#!python
class MapSpotInline(admin.TabularInline):
model = MapSpot
extra = 0
@admin.register(Map)
class MapAdmin(admin.ModelAdmin):
inlines = [MapSpotInline]
}}}
--
Comment:
I believe it affects all inline formsets, not just those in the admin.
There's a [https://github.com/django/django/pull/7094 PR] without tests.
--
Ticket URL: <https://code.djangoproject.com/ticket/26819#comment:17>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.472f07c02740e86724229482b2c0b883%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.