[Django] #21705: Generic Relations fail to detect validation error appropritely

10 views
Skip to first unread message

Django

unread,
Dec 29, 2013, 8:26:10 PM12/29/13
to django-...@googlegroups.com
#21705: Generic Relations fail to detect validation error appropritely
-------------------------+-------------------------------------------------
Reporter: | Owner: nobody
mo_ttds@… | Status: new
Type: Bug | Version: 1.6
Component: | Keywords: AdminSite, GenericRelation,
contrib.admin | unique_together, IntegrityError
Severity: Normal | Has patch: 0
Triage Stage: | UI/UX: 0
Unreviewed |
Easy pickings: 0 |
-------------------------+-------------------------------------------------
Hi. When using a GenericRelation on a Model to create a M2M generic
relation between two other models, with a '''unique_together''' attribute
on the relation. admin site fails to detect '''uniqueness-validation'''
and instead of reporting a unique violation validation error it raises an
'''IntegrityError''' e.g. IntegrityError: columns tag_id, object_id are
not unique

here is the case:
{{{
class Tag(models.Model):
slug = models.SlugField(max_length=100)

def __unicode__(self):
return self.slug

class News(models.Model):
title = models.CharField(max_length=100)

def __unicode__(self):
return self.title

class Tagger(models.Model):
class Meta:
'''unique_together = ('tag', 'object_id')'''

tag = models.ForeignKey(Tag)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
}}}

and creating the admin objects like this:

{{{
class TagAdmin(admin.ModelAdmin):
list_display = ('slug',)

class TabularTagInline(generic.GenericTabularInline):
model = models.Tagger
extra = 2

class NewsAdmin(admin.ModelAdmin):
list_display = ('title', )
inlines = (TabularTagInline,)

admin.site.register(Blog, BlogAdmin)
admin.site.register(Tag, TagAdmin)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21705>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 30, 2013, 5:36:07 AM12/30/13
to django-...@googlegroups.com
#21705: Generic Relations fail to detect validation error appropritely
-------------------------------------+-------------------------------------
Reporter: mo_ttds@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.6
Severity: Normal | Resolution:
Keywords: AdminSite, | Triage Stage:
GenericRelation, unique_together, | Unreviewed
IntegrityError | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by anonymous):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

admin.site.register(Blog, BlogAdmin) should be admin.site.register(News,
BlogAdmin).

--
Ticket URL: <https://code.djangoproject.com/ticket/21705#comment:1>

Django

unread,
Dec 30, 2013, 5:37:22 AM12/30/13
to django-...@googlegroups.com
#21705: Generic Relations fail to detect validation error appropritely
-------------------------------------+-------------------------------------
Reporter: mo_ttds@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.6
Severity: Normal | Resolution:
Keywords: AdminSite, | Triage Stage:
GenericRelation, unique_together, | Unreviewed
IntegrityError | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by anonymous):

sorry.


admin.site.register(Blog, BlogAdmin) should be admin.site.register(News,

NewsAdmin).

--
Ticket URL: <https://code.djangoproject.com/ticket/21705#comment:2>

Django

unread,
Dec 30, 2013, 9:14:29 AM12/30/13
to django-...@googlegroups.com
#21705: Generic Relations fail to detect validation error appropritely
-------------------------------------+-------------------------------------
Reporter: mo_ttds@… | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.6
Severity: Normal | Resolution: invalid

Keywords: AdminSite, | Triage Stage:
GenericRelation, unique_together, | Unreviewed
IntegrityError | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by mo_ttds...):

* status: new => closed
* resolution: => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/21705#comment:3>

Reply all
Reply to author
Forward
0 new messages