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.
--
Ticket URL: <https://code.djangoproject.com/ticket/22977>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* owner: nobody => kswiat
--
Ticket URL: <https://code.djangoproject.com/ticket/22977#comment:1>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/22977#comment:2>
* needs_better_patch: 0 => 1
Comment:
As Loic noted on the PR, we should revisit this after the `_meta` factor
is merged.
--
Ticket URL: <https://code.djangoproject.com/ticket/22977#comment:3>
* owner: kswiat =>
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/22977#comment:4>
* owner: => davide-ceretti
* status: new => assigned
* version: 1.6 => master
--
Ticket URL: <https://code.djangoproject.com/ticket/22977#comment:5>
Comment (by davide-ceretti):
Given loic's comment at
https://github.com/django/django/pull/3359#issuecomment-59642918, what
would be the correct implementation of this validation check? Adding it to
BaseManager.check method?
--
Ticket URL: <https://code.djangoproject.com/ticket/22977#comment:6>
* owner: Davide Ceretti => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/22977#comment:7>
* owner: (none) => Aman Pandey
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/22977#comment:8>