Eliminate InlinePanel.related, as it just duplicates db_field

pull/4504/merge
Matt Westcott 2018-08-14 17:10:17 +01:00
rodzic c3b7a22d73
commit 4cdf7c474e
1 zmienionych plików z 4 dodań i 5 usunięć

Wyświetl plik

@ -648,14 +648,14 @@ class InlinePanel(EditHandler):
return self.panels
# Failing that, get it from the model
return extract_panel_definitions_from_model_class(
self.related.related_model,
exclude=[self.related.field.name]
self.db_field.related_model,
exclude=[self.db_field.field.name]
)
def get_child_edit_handler(self):
panels = self.get_panel_definitions()
child_edit_handler = MultiFieldPanel(panels, heading=self.heading)
return child_edit_handler.bind_to_model(self.related.related_model)
return child_edit_handler.bind_to_model(self.db_field.related_model)
def required_formsets(self):
child_edit_handler = self.get_child_edit_handler()
@ -678,7 +678,7 @@ class InlinePanel(EditHandler):
for panel in self.get_panel_definitions():
field_comparisons.extend(
panel.bind_to_model(self.related.related_model)
panel.bind_to_model(self.db_field.related_model)
.get_comparison())
return [curry(compare.ChildRelationComparison, self.db_field,
@ -687,7 +687,6 @@ class InlinePanel(EditHandler):
def on_model_bound(self):
manager = getattr(self.model, self.relation_name)
self.db_field = manager.rel
self.related = manager.rel
def on_instance_bound(self):
self.formset = self.form.formsets[self.relation_name]