﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12351	GenericRelatedObjectManager get() and get_or_create() should behave like create()	Fred Bartle	nobody	"Given the following models and objects:

{{{

class Attribute(models.Model):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    name = models.CharField(max_length=100)

class MyModel(models.Model):
    name = models.CharField(max_length=100)
    attributes = generic.GenericRelation(Attribute)

>>> obj = MyModel.objects.create(name=""fred"")

}}}

I can create Attributes for my objects easily, without specifying content_type and object_id. The create() interface adds the content_type and object_id to kwargs.

{{{
>>> obj.attributes.create(name=""myattr"")

}}}

When using get() and get_or_create() without specifying content_type and object_id:

{{{
>>> obj.attributes.get_or_create(name=""myattr"")
...
IntegrityError: null value in column ""content_type_id"" violates not-null constraint.
}}}

Obviously, in order to use get() and get_or_create(), I need to specify content_type and object_id. I propose to use the same behavior as create() for ease of use.

"		closed	Contrib apps	1.1		invalid	generic relation		Unreviewed	0	0	0	0	0	0
