Fixed #22064 -- Add check for related_name

Validates that related_name is a valid Python id or ends with a '+' and
it's not a keyword. Without a check it passed silently leading to
unpredictable problems.

Thanks Konrad Świat for the initial work.
This commit is contained in:
André Ericson 2014-10-04 20:47:26 -03:00
parent 8c581ff394
commit 1e5e2a4707
3 changed files with 90 additions and 0 deletions

View file

@ -117,6 +117,8 @@ Related Fields
``<field name>``.
* **fields.E305**: Field name ``<field name>`` clashes with reverse query name
for ``<field name>``.
* **fields.E306**: Related name must be a valid Python identifier or end with
a ``'+'``.
* **fields.E310**: None of the fields ``<field1>``, ``<field2>``, ... on model
``<model>`` have a ``unique=True`` constraint.
* **fields.E311**: ``<model>`` must set ``unique=True`` because it is