#16920: Models with GenericRelation are unnecessarily validated for clashes in reverse manager accessor -------------------+---------------------------------------------- Reporter: r1cky | Owner: nobody Type: Bug | Status: new Milestone: | Component: Database layer (models, ORM) Version: 1.3 | Severity: Normal Keywords: | Triage Stage: Unreviewed Has patch: 0 | Easy pickings: 0 UI/UX: 0 | -------------------+---------------------------------------------- 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'. }}} -- Ticket URL: <https://code.djangoproject.com/ticket/16920> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.