Reputation: 117
I am new to UI design. My objective is to select the multiple items from a dropdown menu and send the selected to a django view. I wrote the entire code and able to select multiple fields using bootstrap+chosen but after submitting I am getting this error:
"GET /static/app/css/chosen-sprite.png HTTP/1.1" 304
After searching in the web, I found out that this file is required as chosen saves the selected items in this file. I have this file in my css folder(downloaded from net) but dont know what I am doing wrong.
Below is my code and right now I am printing the selected items in the same html page. Please help me :(
project_select.html
{% block body %}
<p><br/></p>
<div class="container">
<div class="row">
<div class="col-md-6">
<h3>Select projects:</h3>
<form id="selectProject" role="search" method="get" action="{% url 'displayselectedprojects' %}">
<select form="selectProject" data-placeholder="Choose projects" class="chosen-select" multiple tabindex="4" name="params[]">
{% for project in project_names %}
<option> {{ project.projectname }} </option>
{% endfor %}
</select>
</form>
</div>
<div class="">
<h3><br></h3>
<input type="button" value="Submit" style="padding: 4px 28px;border-radius: 4px;">
</div>
</div>
</div>
<p>Here is selection:</p>
<p>{{ title}} <br />
{{ projectList }}</p>
<script src="http://harvesthq.github.io/chosen/chosen.jquery.js"></script>
<script>
$('.chosen-select').chosen();
</script>
{% endblock %}
urls.py
url(r'displayselectedprojects/', views.displayselectedprojects, name='displayselectedprojects'),
views.py
def displayselectedprojects(request):
selected_packages = request.GET.getlist('params[]')
print('selected packages: %s' % selected_packages)
context = {
'title': 'i reached here',
'projectList': selected_packages,
}
return render(request, 'app/project_select.html', context)
Upvotes: 0
Views: 342
Reputation: 117
I found a solution for the issue, not sure its the actual solution or a workaround but I replaced all the references of the file 'chosen-sprite.png' with its cdn: 'https://cdnjs.cloudflare.com/ajax/libs/chosen/1.7.0/chosen-sprite.png' and its working now.
Upvotes: 1