#15932: related_name='+' ignored in ManyToManyField validation
-------------------------------------+-------------------------------------
Reporter: Fredde | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.3
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 1 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by JannKleen):
* cc: jann@… (added)
* needs_better_patch: 0 => 1
* ui_ux: => 0
Comment:
I applied this patch but ran into some problems.
The m2m-insert worked as expected, but whenever executing .all(), the orm
would create a sql query for the wrong table...
The problem was fixed when i gave all fields unique related_names again...
Model structure:
{{{
class A(models.Model):
tags = models.ManyToManyField('tag', related_name='+')
class Meta:
abstract = True
class B(A):
pass
class C(A):
pass
}}}
Queries:
{{{
>>>b.tags.add(tag)
>>>b.tags.all()
[]
}}}
The .all() produces a SQL query which looks roughly like that: (i.e. the
orm picks the wrong m2m-table for some reason)
{{{
SELECT * FROM "foo_tag" INNER JOIN "foo_c_tags" ON ("foo_tag"."id" =
"foo_c_tags"."tag_id") WHERE "foo_c_tags"."c_id" = 1;
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/15932#comment:2>
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 [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.