76 | | |
77 | | rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() |
78 | | rel_query_name = f.related_query_name() |
79 | | for r in rel_opts.fields: |
80 | | if r.name == rel_name: |
81 | | e.add(opts, "Accessor for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) |
82 | | if r.name == rel_query_name: |
83 | | e.add(opts, "Reverse query name for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) |
84 | | for r in rel_opts.many_to_many: |
85 | | if r.name == rel_name: |
86 | | e.add(opts, "Accessor for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) |
87 | | if r.name == rel_query_name: |
88 | | e.add(opts, "Reverse query name for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) |
89 | | for r in rel_opts.get_all_related_many_to_many_objects(): |
90 | | if r.get_accessor_name() == rel_name: |
91 | | e.add(opts, "Accessor for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) |
92 | | if r.get_accessor_name() == rel_query_name: |
93 | | e.add(opts, "Reverse query name for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) |
94 | | for r in rel_opts.get_all_related_objects(): |
95 | | if r.field is not f: |
| 75 | else: |
| 76 | rel_opts = f.rel.to._meta |
| 77 | rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() |
| 78 | rel_query_name = f.related_query_name() |
| 79 | for r in rel_opts.fields: |
| 80 | if r.name == rel_name: |
| 81 | e.add(opts, "Accessor for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) |
| 82 | if r.name == rel_query_name: |
| 83 | e.add(opts, "Reverse query name for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) |
| 84 | for r in rel_opts.many_to_many: |
| 85 | if r.name == rel_name: |
| 86 | e.add(opts, "Accessor for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) |
| 87 | if r.name == rel_query_name: |
| 88 | e.add(opts, "Reverse query name for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) |
| 89 | for r in rel_opts.get_all_related_many_to_many_objects(): |
99 | | e.add(opts, "Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) |
| 93 | e.add(opts, "Reverse query name for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) |
| 94 | for r in rel_opts.get_all_related_objects(): |
| 95 | if r.field is not f: |
| 96 | if r.get_accessor_name() == rel_name: |
| 97 | e.add(opts, "Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) |
| 98 | if r.get_accessor_name() == rel_query_name: |
| 99 | e.add(opts, "Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) |