Django Modelmultiplechoicefield Widget Not Rendering
I am trying to use the built-in django admin widget ModelMultipleChoiceField to render something like this in a form: I have followed others' recommendations here, and have review
Solution 1:
Figured it out: it is critical to have all form.media
and associated javascripts load before the form loads.
So, instead of:
<linkhref="/static/admin/css/widgets.css"type="text/css"media="all"rel="stylesheet" /><scripttype="text/javascript"src="/jsi18n/"></script><scripttype="text/javascript"src="/static/admin/js/jquery.init.js"></script><formmethod='POST'action=''enctype='multipart/form-data'>{% csrf_token %}
{{ form }}
<inputtype='submit'value='Add Item(s)' /></form>
{{ media }}
Do this (scripts + form.media
placed before form
:
<scripttype="text/javascript"src="/jsi18n/"></script><scripttype="text/javascript"src="/static/admin/js/jquery.min.js"></script><scripttype="text/javascript"src="/static/admin/js/jquery.init.js"></script>
{{ media }}
<formmethod='POST'action=''enctype='multipart/form-data'>{% csrf_token %}
{{ form }}
<inputtype='submit'value='Add Item(s)' /></form>
Post a Comment for "Django Modelmultiplechoicefield Widget Not Rendering"