* owner: outofculture => koirikivi
--
Ticket URL: <https://code.djangoproject.com/ticket/14226#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by koirikivi):
I think the correct way to fix this is to remove models referenced by
complex (with explicit intermediate models i.e. through=...) M2M relations
from the dependency chain, but keep simple (with automatic intermediate
models) in the dependency chain.
This is also the check done by
django.core.serializers.python.Serializer.handle_m2m_field. In serialized
data, simple M2M relations are shown inline with the model that defines
them, which makes dependencies of the referenced models. For complex M2M
relations, however, the intermediate models should be serialized along
with the other models, and should be included as models in the serialized
data. The model defining the M2M relation thus has no dependency to the
other model, but the intermediate model will have a dependency to both of
the M2M models.
Development branch at
https://github.com/koirikivi/django/tree/ticket_14226
Pull request at https://github.com/django/django/pull/1495
All tests pass under sqlite and postgres.
I created quite a few tests to first learn about the issue and then to be
sure that everything works. The ''test_dump_and_load_m2m_complex_*'' tests
are most likely redundant with the other tests in the PR, and can be
removed as seemed fit.
FWIW I also tried the patch posted by aneil, which broke a couple of
tests, and removing the M2M checks altogether, which didn't break any
tests but resulted in a regression that's caught in the tests in the PR
(namely ''test_dependency_sorting_m2m_simple'')
--
Ticket URL: <https://code.djangoproject.com/ticket/14226#comment:13>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/14226#comment:14>
* easy: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/14226#comment:15>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"a75324c6544d728d3bd8f678b1b8021fdff18332"]:
{{{
#!CommitTicketReference repository=""
revision="a75324c6544d728d3bd8f678b1b8021fdff18332"
Fixed #14226 -- Dependency calculation for complex M2M relations.
`sort_dependencies` incorrectly interpreted 'complex' M2M relations
(with explicit through models) as dependencies for a model. This caused
circular complex M2M relations to be unserializable by dumpdata.
Thanks to aneil for the report and outofculture for initial tests.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/14226#comment:16>