tickets: 40
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
40 | 2005-07-17 01:32:23 | 2006-10-22 16:14:52 | 2022-03-06 03:19:33.109198 | Unreviewed | closed | Database layer (models, ORM) | defect | major | fixed | Attempt to set a many to many relation throws exception unless model specifies ordering. | 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. | adrian | jforeman@hark.org | ManyToMany | 0 | 0 | 0 | 0 | 0 | 0 |