Skip to content

Commit

Permalink
Fix media in nested formsets
Browse files Browse the repository at this point in the history
  • Loading branch information
CleitonDeLima committed Oct 15, 2020
1 parent 24b1e0f commit 73cdbab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion easy_formset/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ def nested_names(self):

@property
def media(self):
return self.empty_form.media + self.empty_form.nested.media
media = self.empty_form.media
for name in self.nested_names:
if hasattr(self.empty_form, name):
media += getattr(self.empty_form, name).media

return media


class NestedModelFormset(NestedFormsetMixin, BaseModelFormSet):
Expand Down
1 change: 1 addition & 0 deletions tests/testapp/templates/nestedinlineformset.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h3>Home: {{ object.location }}</h3>
<button type="submit" id="btn-submit">Submit</button>
</form>

{{ formset.media }}
<script src="{% static 'easy_formset/easy_formset.js' %}"></script>
<script>
const formset = new Formset("{{ formset.prefix }}")
Expand Down

0 comments on commit 73cdbab

Please sign in to comment.