﻿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
40	Attempt to set a many to many relation throws exception unless model specifies ordering.	jforeman@…	Adrian Holovaty	"I've got two basic models, with a ManyToManyField connecting them.  An exception is thrown while trying to set the relation:

{{{
class Foo(meta.Model)
    fields = (
        meta.CharField('name', 'name', maxlength=100),
    )

class Bar(meta.Model)
    fields = (
        meta.CharField('name', 'name', maxlength=100),
        meta.ManyToManyField(Foo),
    )


>>> f = foos.get_object(id__exact=1)
>>> b = bars.get_object(id__exact=1)
>>> f.set_bars((b.id,))
Traceback (most recent call last):
  File ""<stdin>"", line 1, in ?
  File ""/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/meta.py"", line 57, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))
  File ""/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/meta.py"", line 897, in method_set_related_many_to_many
    if rel_field.rel.orderable:
AttributeError: ManyToMany instance has no attribute 'orderable'
}}}

If I add an ""ordering = (('name', 'ASC'),)"" to Bar then it works as expected.

The relation should work even without specifying an ordering, however orderable does not seem to be set at all unless I explicitly add ordering to the model."	defect	closed	Database layer (models, ORM)		major	fixed	ManyToMany		Unreviewed	0	0	0	0	0	0
