Created
May 9, 2022 13:36
-
-
Save danilovmy/59f76be725fc2bcdcd0ccb89fe8f7696 to your computer and use it in GitHub Desktop.
form prefix handling for nested inlines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyForm(StackedInline.form): | |
| def __init__(self, *args, **kwargs): | |
| super(MyForm, self).__init__(*args, **kwargs) | |
| self.instance.form = self | |
| class ProductInline(StackedInline): | |
| # ...... | |
| form = MyForm | |
| def image_inline(self, obj=None, *args, **kwargs): | |
| # ...... | |
| inline.formset.prefix = f'{inline.formset.prefix}_{obj.form.prefix}'.replace('-', '_') | |
| # ...... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment