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
16920,Models with GenericRelation are unnecessarily validated for clashes in reverse manager accessor,Ricky Rosario,nobody,"GenericRelation fields don't add a reverse manager to the related model. However, the model validation verifies that there are no collisions forcing the use of an unused related_name parameter (which then can cause issues such as #16913).
'''To reproduce:'''
Create a model with a GenericForeignKey and a related model with a GenericRelation. testapp1/models.py:
{{{
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.db import models
class Topic(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
class Post(models.Model):
topic = generic.GenericRelation(Topic)
}}}
In a different app, create another related model with the same name. testapp2/models.py:
{{{
from django.contrib.contenttypes import generic
from django.db import models
from testapp1.models import Topic
class Post(models.Model):
topic = generic.GenericRelation(Topic)
}}}
Now run syncdb:
{{{
$ ./manage.py syncdb
Error: One or more models did not validate:
testapp2.post: Accessor for m2m field 'topic' clashes with related m2m field 'Topic.post_set'. Add a related_name argument to the definition for 'topic'.
testapp1.post: Accessor for m2m field 'topic' clashes with related m2m field 'Topic.post_set'. Add a related_name argument to the definition for 'topic'.
}}}",Bug,new,contrib.contenttypes,1.3,Normal,,,james@… 4glitch@…,Accepted,1,0,0,1,0,0