﻿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
22977	No validation error when ForeignKey related_name clashes with manager name.	Russell Keith-Magee	Mariusz Felisiak	"Consider the following model definition:
{{{
class Author(models.Model):
    authors = models.Manager()

    name = models.CharField(max_length=100)

    mentor = models.ForeignKey('self', related_name='authors')
}}}

The related name on the the foreign key clashes with the manager, so when you try to issue a query:
{{{
    Author.authors.filter(name__startswith='Douglas')
}}}

you get an error because ""Author.authors has no attribute 'filter'"". 

The problem is order dependent; if you define the manager *after* the foreign key, you get different errors.

I haven't checked what errors you get if you just have the default Manager, and a related_name of 'objects'.

There may also be problems if you have a field named 'objects'. 

I suspect this class of problem could be picked up by the system check framework.
"	Cleanup/optimization	closed	Core (System checks)	dev	Normal	fixed		Mariusz Felisiak	Ready for checkin	1	0	0	0	0	0
