Hi, Sorry for the late reply. Does simply using {{ formset.media }} work?
Collin On Friday, February 13, 2015 at 11:02:31 AM UTC-5, aRkadeFR wrote: > > Hello everyone, > > I'm using FormSet in order to add multiple object at once on > a view. To have a more user friendly approach, I created a > 'my.formset.js' file and I need to include a 'jquery.formset.js' lib > to add/remove row of the formset (client side) and edit the > formset management information. > > My idea to resolve this problem was to include these two > javascript media file everytime I'm using a formset. > > A bit like every media js file for widgets :) > > So my first attempt was something like that: > ``` > class BaseFormSet(BaseInlineFormSet): > class Media: > js = ("my.formset.js", "jquery.formset.js", ) > ``` > > but this doesnt render these js files with formset.media.render_js(). > > My second attempt was: > ``` > formset.media.add_js( ["my.formset.js", "jquery.formset.js", ]) > ``` > > My last attempt: > ``` > form = formset.forms[0] > formset.forms[0].fields[form.fields.keys()[0]].media.add_js(["my.formset.js", > > "jquery.formset.js", ]) > ``` > > Still not working cause the .media._js is regenerating the media js > files. > > The only solution so far I have, provided by @tbaxter, is to > include all my js files in all my application, and initialize/use > the formset/widgets javascript only on certain condition. > > I don't like the idea of including my js application wide. It's > gonna overload all my pages for nothing (my js files are > completely standalone) when there is no FormSet. > > Can I have your tought on this probleme, and what solution > you have in mind? > > Thank you, > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/eb5af3a3-d09f-4562-b290-fec7f763e74e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.