I use this model:
class Another(models.Model):
name = models.CharField(maxlength=20, core=True)
another = models.ForeignKey('self', null=True, related_name='child_set')
Note that the field name another is like the model name, only lower case.
The following code fails:
Another.AddManipulator().save(dict(id='3', name='Another root category', another=None))
This might be an intended restriction, but then it should be checked by model validation. When it strikes, it's rather surprising because you don't see any connection to the attribute name in the backtrace. And it's probably a common thing to name the self relationship after the table.
This is the exception:
Exception: File "/home/mir/src/django/trunk/tests/doctest.py", line 1243, in __run
compileflags, 1) in test.globs
File "<doctest m2o_recursive[10]>", line 1, in ?
anotherone = Another.AddManipulator().save(dict(id='3', name='Another root category', another=None))
File "/home/mir/src/django/active/django/db/models/manipulators.py", line 75, in __init__
self.fields.extend(f.get_manipulator_fields(self.opts, self, self.change, fol))
File "/home/mir/src/django/active/django/db/models/related.py", line 112, in get_manipulator_fields
if follow.get(f.name, False):
AttributeError: 'bool' object has no attribute 'get'
db.models.related.RelatedObject?.get_manipulator_fields expects a dictionary in follow. But db.models.maniplators.init() sends True.