You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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))
85
-
ifr.name==rel_query_name:
86
-
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))
87
-
forrinrel_opts.local_many_to_many:
88
-
ifr.name==rel_name:
89
-
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))
90
-
ifr.name==rel_query_name:
91
-
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))
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))
95
-
ifr.get_accessor_name() ==rel_query_name:
96
-
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))
97
-
forrinrel_opts.get_all_related_objects():
98
-
ifr.fieldisnotf:
82
+
ifnotf.rel.is_hidden():
83
+
forrinrel_opts.fields:
84
+
ifr.name==rel_name:
85
+
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))
86
+
ifr.name==rel_query_name:
87
+
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))
88
+
forrinrel_opts.local_many_to_many:
89
+
ifr.name==rel_name:
90
+
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))
91
+
ifr.name==rel_query_name:
92
+
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))
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))
95
+
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))
101
96
ifr.get_accessor_name() ==rel_query_name:
102
-
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))
97
+
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))
98
+
forrinrel_opts.get_all_related_objects():
99
+
ifr.fieldisnotf:
100
+
ifr.get_accessor_name() ==rel_name:
101
+
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))
102
+
ifr.get_accessor_name() ==rel_query_name:
103
+
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))
e.add(opts, "ManyToManyFields cannot be unique. Remove the unique argument on '%s'."%f.name)
119
120
120
-
ifgetattr(f.rel, 'through', None) isnotNone:
121
-
ifhasattr(f.rel, 'through_model'):
122
-
from_model, to_model=cls, f.rel.to
123
-
iffrom_model==to_modelandf.rel.symmetrical:
124
-
e.add(opts, "Many-to-many fields with intermediate tables cannot be symmetrical.")
125
-
seen_from, seen_to, seen_self=False, False, 0
126
-
forinter_fieldinf.rel.through_model._meta.fields:
127
-
rel_to=getattr(inter_field.rel, 'to', None)
128
-
iffrom_model==to_model: # relation to self
129
-
ifrel_to==from_model:
130
-
seen_self+=1
131
-
ifseen_self>2:
132
-
e.add(opts, "Intermediary model %s has more than two foreign keys to %s, which is ambiguous and is not permitted."% (f.rel.through_model._meta.object_name, from_model._meta.object_name))
133
-
else:
134
-
ifrel_to==from_model:
135
-
ifseen_from:
136
-
e.add(opts, "Intermediary model %s has more than one foreign key to %s, which is ambiguous and is not permitted."% (f.rel.through_model._meta.object_name, from_model._meta.object_name))
137
-
else:
138
-
seen_from=True
139
-
elifrel_to==to_model:
140
-
ifseen_to:
141
-
e.add(opts, "Intermediary model %s has more than one foreign key to %s, which is ambiguous and is not permitted."% (f.rel.through_model._meta.object_name, rel_to._meta.object_name))
142
-
else:
143
-
seen_to=True
144
-
iff.rel.through_modelnotinmodels.get_models():
145
-
e.add(opts, "'%s' specifies an m2m relation through model %s, which has not been installed."% (f.name, f.rel.through))
146
-
signature= (f.rel.to, cls, f.rel.through_model)
147
-
ifsignatureinseen_intermediary_signatures:
148
-
e.add(opts, "The model %s has two manually-defined m2m relations through the model %s, which is not permitted. Please consider using an extra field on your intermediary model instead."% (cls._meta.object_name, f.rel.through_model._meta.object_name))
e.add(opts, "Many-to-many fields with intermediate tables cannot be symmetrical.")
125
+
seen_from, seen_to, seen_self=False, False, 0
126
+
forinter_fieldinf.rel.through._meta.fields:
127
+
rel_to=getattr(inter_field.rel, 'to', None)
128
+
iffrom_model==to_model: # relation to self
129
+
ifrel_to==from_model:
130
+
seen_self+=1
131
+
ifseen_self>2:
132
+
e.add(opts, "Intermediary model %s has more than "
133
+
"two foreign keys to %s, which is ambiguous "
134
+
"and is not permitted."% (
135
+
f.rel.through._meta.object_name,
136
+
from_model._meta.object_name
137
+
)
138
+
)
149
139
else:
150
-
seen_intermediary_signatures.append(signature)
151
-
seen_related_fk, seen_this_fk=False, False
152
-
forfieldinf.rel.through_model._meta.fields:
153
-
iffield.rel:
154
-
ifnotseen_related_fkandfield.rel.to==f.rel.to:
155
-
seen_related_fk=True
156
-
eliffield.rel.to==cls:
157
-
seen_this_fk=True
158
-
ifnotseen_related_fkornotseen_this_fk:
159
-
e.add(opts, "'%s' has a manually-defined m2m relation through model %s, which does not have foreign keys to %s and %s"% (f.name, f.rel.through, f.rel.to._meta.object_name, cls._meta.object_name))
0 commit comments