rabbagliettiandrea / dj-nested-inlines

Adds nested inline support in Django admin
38 stars 34 forks source link

Add inlines.min.js. #13

Closed sandinmyjoints closed 9 years ago

sandinmyjoints commented 10 years ago

In normal Django (without django-nested-inlines), a script tag to load js is inserted into the admin template when inlines are used. It is loaded through django/contrib/admin/options.py. If you are not in debug mode, instead of inlines.js, it will load inlines.min.js.

If you use django-nested-inlines, then Django will see the Media class in nested_inlines/admin.py that says to use inlines.js, so it will insert a script tag to load inlines.js into the admin template.

In debug mode, everything appears fine. There are two script tags that both load inlines.js, and they both load django-nested-inlines inlines.js.

When I ran my app not in debug mode, then there were two script tags like this:

<script type="text/javascript" src="http://example.com/admin/js/inlines.js"></script>
<script type="text/javascript" src="http://example.com/admin/js/inlines.min.js"></script>

Django collectstatic found django-nested-inlines version of inlines.js and it also found Django's own inlines.min.js, and because I was running not in debug mode, options.py inserted a script tag for inlines.min.js which is the normal Django file. Because for some reason it came after django-nested-inlines inlines.js, it overrode the functions defined in that file, and this broke nested inllnes.

A quick fix is to add inlines.min.js (minified version of django-nested-inlines inlines.js).