New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #26729 -- Allowed overriding the label of a tabular inline form field #6804
Conversation
@@ -279,7 +279,7 @@ def fields(self): | |||
'help_text': help_text_for_field(field_name, self.opts.model), | |||
} | |||
else: | |||
form_field = self.formset.form.base_fields[field_name] | |||
form_field = self.formset.empty_form.fields[field_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat trick.
Could you try to reuse an existing set of models? We try to avoid new models unless absolutely necessary since they slow the test suite. Also, if it's possible to write the assertion by accessing the appropriate object in |
@timgraham |
Something like |
@timgraham response = self.client.get(reverse('admin:admin_inlines_anotherparentmodel_add'))
field = list(response.context['inline_admin_formset'].fields())[0]
self.assertEqual(field['label'], 'new label') |
I think it's an improvement since that gives some idea of where to look in the event of a test breakage. With |
@timgraham Thanks for review. I've updated the pr to reuse model and do more explicit test. |
merged in 9c2d5a8, thanks! I removed the ticket references. For future reference, we typically include them for obscure issues where the additional context of the ticket is helpful in understanding the issue. |
https://code.djangoproject.com/ticket/26729