﻿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
1839	ForeignKey('self') with attribute name like model name breaks AddManipulator().save()	mir@…	Adrian Holovaty	"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`.
"	defect	closed	Database layer (models, ORM)	dev	normal	fixed		django@… gabor@…	Accepted	0	0	1	0	0	0
