Reputation: 441
I have this kind of problem: I don't load my data in a django bootstrap (22.3.2) modal window .I want to load a text given its index. I don't know where si my error. Thi si my code
MAIN.HTML
<a data-toggle="modal" href="show_modal_topic.html/{{topic_id}}/" data-target="#myModal">click me</a>
{% include "show_modal_topic.html" %}
URLS.PY
url(r'^show_modal_topic.html/(\d+)/$', views_topics.load_topic),
VIEWS.PY
def load_topic(request, topic_id):
topic = tab_topics.objects.get(id_topic=topic_id)
text_topic = topic.text
return render_to_response("show_modal_topic.html", {
'text_topic': text_topic,
},
context_instance=RequestContext(request))
SHOW_MODAL_TOPIC.HTML
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Opinione</h4>
</div>
<div class="modal-body">
{{text_topic}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Can you help me please? I can not understand where I'm wrong. thanks
Upvotes: 0
Views: 619
Reputation: 53326
I think you need to update your urls.py to define variable name passed to the view as
url(r'^show_modal_topic.html/(?P<topic_id>\d+)/$', views_topics.load_topic),
Upvotes: 1