1๐
โ
I have found a more django-esk way of fixing this, figured I would add it if anyone comes across this issue. This is working in both 1.8 and 1.10.1
I put the addEvent call into an external js file ./static/js/catsfilter.js
addEvent(window, "load", function(e) {SelectFilter.init("id_cats", "Categories", 0, "/static/admin/"); });
Created a Media subclass on my form to call the js
class Media:
js = ("js/catsfilter.js",)
And removed the call to core.js, SelectBox.js and SelectFilter2, replaced with a call to the forms media in my base.html head section
<script type="text/javascript" src="{% static 'js/jsi18n.js' %}"></script>
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
{{ form.media }}
๐คEdyoucaterself
1๐
I added put the script directly into my template and its working now.
<div class="form-group">
{% csrf_token %}
{{ form.as_table }}
<script type="text/javascript">addEvent(window, "load", function(e) {SelectFilter.init("id_cats", "Categories", 0, "/static/admin/"); });</script>
</div>
๐คEdyoucaterself
- [Answered ]-Rewrite form with django forms
- [Answered ]-Django view didn't return an HttpResponse object
Source:stackexchange.com