#13091: admin list_editable with unique_together raises Integrity Error
----------------------------------------------------------+-----------------
Reporter: slafs | Owner:
nobody
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Keywords: list_editable unique_together IntegrityError | Stage:
Unreviewed
Has_patch: 0 |
----------------------------------------------------------+-----------------
I'm getting an Integrity Error when trying to edit (on changelist) a model
that has some unique_together fields and is
registered with list_editable containing some of that fields (not all of
them).
Example
{{{
#models.py
class Test(models.Model):
t1 = models.CharField(max_length=255, blank=True, null=True)
t2 = models.CharField(max_length=255, blank=True, null=True)
t3 = models.CharField(max_length=255, blank=True, null=True)
class Meta:
unique_together = ['t1','t2','t3']
#admin.py
class TestAdmin(admin.ModelAdmin):
list_display = ['t3', 't1', 't2']
list_editable = ['t1', 't2',]
admin.site.register(Test, TestAdmin)
}}}
the changelist form (?) doesn't check the uniqueness of an edited record.
Integrity Error is raised when for example having two rows -
first: t1 = 'a', t2 = 'b', t3 = 'z'
and second: t1 = 'a', t2 = 'a', t3 = 'z'
and trying to change the t2 in first row to 'a'.
In case when all fields from unique_together are in list_editable, the
error message does show. However it isn't very informative (only "Please
correct the errors below." but nothing below is indicated).
Done this on sqlite3 and PostgreSQL.
--
Ticket URL: <http://code.djangoproject.com/ticket/13091>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.